How do I invoke the SP and populate the textboxes?

ugh3012

Member
Joined
Feb 20, 2007
Messages
13
Programming Experience
5-10
I don't do much work in .Net, but I am expecting to develop and maintain a small in house application. I got some stuff done, but I cannot get one part to work right. I am trying to figure out how to invoke a stored procedure and load the return data set to text boxes. I tried to Google it, but I am not finding what I am looking for. I think it is because I am not using the correct search word.

Any help would appreciated. Thanks

Here is what I have so far.

VB.NET:
        Dim Conn As SqlConnection = New SqlConnection(db.DatabaseConnStr)
        Dim cmd As New SqlCommand
        Dim ds As New DataSet
        Dim da As New SqlDataAdapter

        Try

            Conn.Open()

            cmd.CommandType = CommandType.StoredProcedure
            cmd.Connection = Conn
            cmd.Parameters.AddWithValue("@ID", ID)
            ' cmd.CommandText = cmdStr

            Dim Adapter As SqlDataAdapter = New SqlDataAdapter(cmd)
            Dim DataSet As DataSet = New DataSet("name")

            P.lastName = DataSet




        Catch ex As Exception
           
        End Try
 
You call the Fill method of your data adapter and it will populate a DataTable. If all you want is that one result set then simply create a DataTable and pass it as an argument to Fill. If you actually need a DataSet then pass it and the name of the DataTable as arguments. The DataTable will then be created automatically in the DataSet.

That said, if you're only retrieving a single record then you might want to consider using a data reader instead. Check out these code examples:

Retrieving and Saving Data in Databases
 
Back
Top