InfoPath VB Create Connection to SQL RRS feed

  • Question

  • Public Sub btnLoan_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
          Dim conn As New SqlConnection("data source=server;initial catalog=database;Integrated Security=SSPI;")
          Dim nav As XPathNavigator = CreateNavigator()
          Dim theLoanNumber As String
          theLoanNumber = nav.SelectSingleNode("/my:myFields/my:LoanNumber", NamespaceManager).Value
          Dim cmdQuery As New SqlCommand("SELECT ApproverLevel from Approver_Level where LoanNum = '" + theLoanNumber + "'", conn)
          Dim dr As SqlDataReader
            dr = cmdQuery.ExecuteReader()
            Do While dr.Read()
              ' nav.SelectSingleNode("/my:myFields/my:SASELevel", NamespaceManager).SetValue(dr("Approver_Level")(0))
          Catch ex As Exception
          End Try
        End Sub

    I originally had performance issues with InfoPaths data connections. I am trying to do a very simple task. Query one textboxes value for another value that would be put into a different textbox. The ADO connection through infopath was taking a few minutes to even process the query so I took a different approach.

    I removed the server name and database name on purpose in the example. I also added 4 refrences:

    Imports System.Data
    Imports System.Data.Common
    Imports System.Data.Common.DbCommand
    Imports System.Data.Common.DbDataReader
    Imports System.Data.SqlClient

    Currently it doesn't seem like the form is making a connection, and I'm puzzled as to why. To test it I had the query output value go to a message box, and even that wasn't triggering.

    Anyone have any thoughts on what is flawed?


    Friday, February 11, 2011 3:23 PM