Entry
Visual Studio Basic.NET: ASP.NET: Database: Microsoft SQL server: How create SQL query for 2 tables?
Dec 29th, 2003 17:23
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 30 December 2003 - 02:21 am -------------------
Visual Studio Basic.NET: ASP.NET: Database: Microsoft SQL server: How
create SQL query for 2 tables?
---
Steps: Overview:
1. -Create a new ASP.NET project
2. -Put on a form:
1. 2 text boxes
2. 2 buttons
3. 2 datagrids
2. -Create a database connection
1. Run SQLAdapter
2. Put SQLConnection on the form
1. Add to the connection string
; password=<your password>
3. -Put a dataset on your form
1. Possibly put property
'EnforceConstraints'
to false
4. -Put the initial SQL query in
the 2 textboxes
1. Click on textbox 1 and fill
in in the 'text' property
'SELECT * FROM <your tablename1>'
2. Click on textbox 2 and fill
in in the 'text' property
'SELECT * FROM <your tablename2'
5. -Put the following code under the
2 buttons
1. Double click on button 1 and
fill in the on click event:
SqlDataAdapter1.SelectCommand.CommandText = TextBox1.Text
SqlDataAdapter1.Fill(Me.DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
2. Double click on button 2 and
fill in the on click event:
SqlDataAdapter1.SelectCommand.CommandText = TextBox2.Text
SqlDataAdapter1.Fill(Me.DataSet11)
DataGrid2.DataSource = DataSet11
DataGrid2.DataBind()
6. -Run this program
1. Clicking on button 1 shows the current content
of <your tablename1>
2. Clicking on button 2 shows the current content
of <your tablename2>
----------------------------------------------------------------------