Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Executing Stored Procs With Params
Message
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
00979533
Message ID:
00979763
Views:
26
Ok, I have another question.

I am trying to duplicate your procedure for passing an
array of parameters.

Here's my calling code:
  Dim aSqlParms = New ArrayList
  aSqlParms.Add(New SqlParameter("@Country", "France"))
  aSqlParms.Add(New SqlParameter("@PostalCode", "67000"))

  Stuff.StoredProcExample2("sp_GetCustomer", "Customers", aSqlParms)
and the code that does the calling. The 'Fill' call generates a
'System Error'
Public Sub StoredProcExample2(ByVal sProcName As String, ByVal sTable As String, ByRef aParameters As ArrayList)

        ' Create a new Connection
        Dim oConnection As SqlConnection
        oConnection = New SqlConnection("data source=(local);initial catalog=Northwind; user id=kevin; password=googler1")
        oConnection.Open()

        Dim oDataSet = New DataSet

        Dim oSqlAdapter = New SqlDataAdapter(sProcName, oConnection)

        oSqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

        Dim oParms As New SqlParameter
        For Each oParms In aParameters

            oSqlAdapter.SelectCommand.Parameters.Add(oParms)

        Next

        Dim iRowCount As Integer
        iRowCount = oSqlAdapter.Fill(oDataSet, sTable)
        MsgBox(iRowCount)

        Dim oDataRow As DataRow
        Dim sString As String

        For Each oDataRow In oDataSet.Tables(sTable).Rows

            sString = sString & oDataRow("CustomerId") & ControlChars.CrLf & _
            sString = sString & oDataRow("CompanyName") & ControlChars.CrLf & _
            sString = sString & oDataRow("Country") & ControlChars.CrLf & _
            sString = sString & oDataRow("PostalCode")

            MsgBox(sString)

            sString = ""
        Next

        oConnection.Close()

    End Sub
>Hey, Kevin,
>
>The 2nd parameter for Fill() allows you to specify the name of the datatable in the result set.
>
>If you step through the code, you'll notice that right after the fill() executes, the datatable's tablename property is automatically set to whatever you specified in the fill().
>
>Kevin
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform