Dynamically Change Data Connection

V

Veelicus

Kalyan G Reddy MVP (GGK Tech) said:
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!
 
K

Kalyan G Reddy MVP (GGK Tech)

Hello

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

Veelicus

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?
 
A

Andy Bonner

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

Veelicus said:
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?


Kalyan G Reddy MVP (GGK Tech) said:
Hello

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

Veelicus

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 :)

Andy Bonner said:
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

Veelicus said:
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?


Kalyan G Reddy MVP (GGK Tech) said:
Hello

Webservice is one kind of a dataconnection. Which Dataconnection are you
trying to change dynamically?
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:



:

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!
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

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.n...populate-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!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top