Private Sub getData(ByVal user As String)
Dim dt As New DataTable()
Dim connection As New SqlConnection("testConnectionString")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT * from TABLE WHERE Table_Registration = @usersID", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.AddWithValue("@usersID", user)
sqlDa.Fill(dt)
If dt.Rows.Count > 0 Then
txt_B_Name.Text = dt.Rows(3)("ColumnName1").ToString() 'Where ColumnName is the Field from the DB that you want to display
txt_B_numberTeL.Text = dt.Rows(4)("ColumnName2").ToString()
End If
connection.Close()
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET