Question : How to populate a textbox from sqldb storedprocedure

Hello experts,
I wanted to create a simple web page where there are three controls on it.
DropDownList1 (SQLDatasource)
Textbox1
Textbox2
What i wanted to happen is that if a value is selected in the dropdownlist1 on post back the two textboxes will be automatically populated by value from a stroed procedure using the value selected in dropdownlist as a parameter.
But for obvious reason (that i could not figure out) i'm having an error.
Compiler Error Message: BC30456: 'Rows' is not a member of 'System.Data.DataSet'.

I'd appreciate any help on this one
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

        


-----


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Using conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnString2").ConnectionString)
            Dim cmd As New Data.SqlClient.SqlCommand("GetColAColB", conn)
            cmd.CommandType = Data.CommandType.StoredProcedure
            conn.Open()

            cmd.Parameters.Add("@X", Data.SqlDbType.VarChar)

            Dim da As New Data.SqlClient.SqlDataAdapter(cmd)
            Dim ds As New Data.DataSet
            da.Fill(ds)
            If (ds.Rows.Count > 0) Then
                Textbox1.Text = ds.Rows(0)("ColA").ToString();
                TextBox2.Text = ds.Rows(0)("ColB").ToString();
            End If

            conn.Close()
        End Using
    End Sub

Answer : How to populate a textbox from sqldb storedprocedure

If (ds.Tables[0].Rows.Count > 0) Then
Random Solutions  
 
programming4us programming4us