Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2007

Tip: Looking for answers? Try searching our database.

Dynamically Change Data Connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Veelicus - 07 Aug 2007 10:50 GMT
Hi all!

I would like to know how to change dynamically, by code, the DataConnection,
because i can't find a method or property to change it.

I have read
http://enterprise-solutions.swits.net/infopath2007/programmatically-fill-populat
e-drop-down-list-box-infopath-2007.htm


but that's not what i need.

I need to change the connection Dynamically.

Can someone help me?

thanks in advance!!!
Kalyan G Reddy MVP (GGK Tech) - 07 Aug 2007 11:04 GMT
Hello

Please read the link below
http://www.infopathdev.com/forums/thread/17465.aspx

I hope it helps you
Signature

Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com

> Hi all!
>
[quoted text clipped - 11 lines]
>
> thanks in advance!!!
Veelicus - 07 Aug 2007 11:20 GMT
> Hello
>
> Please read the link below
> http://www.infopathdev.com/forums/thread/17465.aspx
>
> I hope it helps you

Hi Kalyan, thanks for your help.

That article is very usefull for me while using Web Services, but i would
like to know if it's posible to change te Data Connection in an infopath 2007
form, by code, without using Web Services or anything else, just code.

thx a lot!

> > Hi all!
> >
[quoted text clipped - 11 lines]
> >
> > thanks in advance!!!
Kalyan G Reddy MVP (GGK Tech) - 07 Aug 2007 11:38 GMT
Hello

Webservice is one kind of a dataconnection. Which Dataconnection are you
trying to change dynamically?
Signature

Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com

> > Hello
> >
[quoted text clipped - 26 lines]
> > >
> > > thanks in advance!!!
Veelicus - 07 Aug 2007 12:12 GMT
Hi again.

I am using a Data Origin, it's a connection from an Sql server 2005.

I write this code:
 
           foreach (DataConnection conexion in DataConnections)
           {                
               conexion.Name.ToString();                
           }

and conexion is the DataConnection, made while desiging the template.

While debugging, i look into conexion.

and this is what i see

-    conexion    {Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost}    Microsoft.Office.InfoPath.DataConnection
{Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost}
-        [Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost]    {Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost}    Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost
+        base    {Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost}    Microsoft.Office.InfoPath.AdoQueryConnection
{Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost}
        Command    "select \"Nombre\",\"Apellido1\",\"Apellido2\",\"Delegacion\" from
\"dbo\".\"PruebasMoss\" as \"PruebasMoss\""    string
        Connection    "Provider=SQLOLEDB.1;Password=User;Persist Security
Info=True;User ID=User;Initial Catalog=TestDB;Data Source=192.168.2.7;Use
Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation
ID=C3-0002;Use Encryption for Data=False;Tag with column collation when
possible=False"    string
        Name    "PruebasMoss"    string
        Timeout    30    int
+        Miembros no públicos       
        Name    "PruebasMoss"    string


The code i want to change is the Command and the Connection string
Dynamically.

Any idea on how to do it?

> Hello
>
[quoted text clipped - 31 lines]
> > > >
> > > > thanks in advance!!!
Andy Bonner - 07 Aug 2007 22:05 GMT
Try this

   foreach (AdoQueryConnection conexion in DataConnections)
   {
       conexion.Command = "whatever you want it to be";
       conexion.Connection = "whatever you need this to be";
   }

HTH
Andy

> Hi again.
>
[quoted text clipped - 77 lines]
>> > > >
>> > > > thanks in advance!!!
Veelicus - 08 Aug 2007 08:03 GMT
Thx Andy, that was what i need and also gave me an idea on how to solve
another problems!!!

Thx for Kalyan too for trying to help :)

> Try this
>
[quoted text clipped - 88 lines]
> >> > > >
> >> > > > thanks in advance!!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.