Hi Susie,
Below is a sample which shows selection from multiple tables as you
requested. For more information, please see this article.
301216 HOW TO: Populate a DataSet Object from a Database by Using Visual
Basic
http://kb/article.asp?id=Q301216
I placed a datagrid on a page and left it with autogenerate columns. Then I
added the following to the code-behind.
If Not IsPostBack Then
Bind()
End If
End Sub
Private Sub Bind()
Dim connectionString As String = "server='localhost';
trusted_connection=true; Database='pubs'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT a.au_fname, a.au_lname, t.title
FROM titles t inner join titleauthor ta on t.title_id = ta.title_id inner
join authors a on ta.au_id = a.au_id"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
Dim sqlAdapter As New SqlClient.SqlDataAdapter(sqlCommand)
Dim ds As New Data.DataSet
sqlAdapter.Fill(ds, "data")
DataGrid1.DataSource = ds.Tables("data")
DataGrid1.DataBind()
sqlAdapter.Dispose()
sqlCommand.Dispose()
sqlConnection.Close()
sqlConnection.Dispose()
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------