VBdotnet2005
asked on
SQL - Fill
I need to retreive data from my SQL database , table name is CustomerAddress. Why it is not working?
..........
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.txtTNum.Text <> "" Then
DataSet11.Clear()
SqlDataAdapter1.SelectComm and.Comman dText = "select * from results Where " & _
"transno = " & Me.txtTNum.Text
SqlDataAdapter1.Fill(DataS et11)
Display(DataSet11)
End If
End Sub
Private Sub Display(ByVal DataSet As DataSet)
Dim dataTable As DataTable = DataSet.Tables(0)
If dataTable.Rows.Count <> 0 Then
Dim recordNumber As Integer = Convert.ToInt32(dataTable. Rows(0)(0) )
Me.txtAddress.Text = CStr(dataTable.Rows(0)(1))
Me.txtCity.Text = CStr(dataTable.Rows(0)(2))
Me.txtState.Text = CStr(dataTable.Rows(0)(3))
End If
End Sub
End Class
..........
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.txtTNum.Text <> "" Then
DataSet11.Clear()
SqlDataAdapter1.SelectComm
"transno = " & Me.txtTNum.Text
SqlDataAdapter1.Fill(DataS
Display(DataSet11)
End If
End Sub
Private Sub Display(ByVal DataSet As DataSet)
Dim dataTable As DataTable = DataSet.Tables(0)
If dataTable.Rows.Count <> 0 Then
Dim recordNumber As Integer = Convert.ToInt32(dataTable.
Me.txtAddress.Text = CStr(dataTable.Rows(0)(1))
Me.txtCity.Text = CStr(dataTable.Rows(0)(2))
Me.txtState.Text = CStr(dataTable.Rows(0)(3))
End If
End Sub
End Class
Are you getting any exceptions ? Have you checked your query to make sure it is returning any results ?
I would guess that the Data adapter hasn't been set up correctly with the correct connection string, opening the connection to the database etc.
If you provide a little more info maybe I could be more specific, but that would be my best guess now.
Drew
If you provide a little more info maybe I could be more specific, but that would be my best guess now.
Drew
ASKER
Ok. do you know any similair links to anything like above sample on how to retreive data and fill in appropriate textboxes?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.