It looks like from the code I am not allowed to use ADO.NET.
I have the following code on the changed event of a field:
SqlConnection conn = new SqlConnection("User
Id=myuser;Password=myPassword;Initial Catalog=mydabtase;Data
Source=myserver");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
iCDO_LTF_Issuer_FR_Rating_View; SELECT * FROM
iCDO_LTF_Issuer_MR_Rating_View;", conn);
da.TableMappings.Add("iCDO_LTF_Issuer_FR_Rating_View",
"iCDO_LTF_Issuer_MR_Rating_View");
DataSet ds = new DataSet();
da.Fill(ds);
The Error is:
System.Security.SecurityException
Request for the permission of type
'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at
System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection
outerConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at LTFTESTForms.FormCode.ddlbCreditName_Changed(Object sender,
XmlEventArgs e)
at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object
genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
at
Microsoft.Office.InfoPath.Internal.XmlEventHost.ChangedProxy(DataDOMEvent
dataDOMEvent)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)
S.Y.M. Wong-A-Ton said:
I don't think you'll find an article specifc to InfoPath on how to do this,
but you can use normal classes from the System.Data and System.Data.SqlClient
to do what you want to do. The only InfoPath specific feature in your
scenario is retrieving and setting values of InfoPath fields. So if you
already know how to work with SqlConnection, SqlCommand, SqlParameter, and
DataSet, you've got your answer on how to call a stored procedure.
There is also this old article (
http://support.microsoft.com/kb/827007), but
I don't think it'll help you much in InfoPath 2007.