I have 1 form whose columns are slno,type,shape
and another form where i want to retrive data from database using combo box.
if i select slno from combo box in form2,then rest of the fields should display in other textbox in form2.
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
'Dim dr As New SqlDataReader
Dim ds As New DataSet
For Each row As DataRow In ds.Tables("data").Rows
If row(0).ToString = ComboBox1.Text Then
TextBox3.Text = row(1).ToString()
TextBox4.Text = row(2).ToString()
Exit For
End If
Next
Quoted Text Here
please can you give me the whole code in vb.net2008 as i am using vb.net 2008 and sqlserver 2005
but its showing error as Object reference not set to an instance of an object in the below line
For Each row As DataRow In ds.Tables("data").Rows