Thanks Hilary,
For the "Name of the Data Source", doesn't that have to be a predefined Data connection in Infopath? What I find is that these data connections all require a table to be added. However for my form, I only want to execute a store procedure that already queries a table.
I tried using the conventional VB programming where:
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
conn.ConnectionString = "driver={SQL Server};server=****;uid=****;pwd=****;database=database"
conn.Open()
cmd.ActiveConnection = conn
Dim startDateXMLNode As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("//my:txt_StartDate")
Dim startDateString As String = startDateXMLNode.text.Replace("-", "")
Dim querySQL As String = "EXEC database.dbo.Export " + startDateString
Dim ResultSet As New ADODB.Recordset
cmd.CommandText = querySQL
cmd.Execute()
However using this method I get an error saying:
System.Security.SecurityException
That assembly does not allow partially trusted callers.
at Timberline_Timesheet_Export.Timberline_Timesheet_Export.btn_Export_OnClick(DocActionEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
A little confused with that, so I moved away and used your code. Except it needs a data source which I'm not sure how to create.