Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to add multiple data connections to an infopath form in the codebehind. I see that I can connect to a db file , but not straight to sql server. Is this possible?

Thanks,

share|improve this question
add comment

1 Answer 1

I'm trying to add multiple data connections to an infopath form in the codebehind. I see that I can connect to a db file , but not straight to sql server. Is this possible?

I am not sure what you mean under "data" in "data connection" connecting to an SQL Server but not to db file.

Codebehind is run in/from Infopath XML data forms created (opened, modified,saved, submitted, etc.) on the basis of (linked to) XSN form templates. The latter contain code behind to be uploaded and used in the former.

While it is possible to create, modify existing and execute data connections on the fly in code behind, it is senseless to speak about adding them to forms themselves (since the form definition and their code behind are in template) but only through changing a template and then republishing and relinking previously created XML data to a new template

Here is the an example of how to change on the fly already existing (specially created for this in template) data connection.

And I strongly discourage you to use code behind. It is against Infopath paradigm and Sharepoint philosophy, architecture and security model of engaging the Infopath as client based and codeless approach.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.