Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting database data on to web form

Status
Not open for further replies.

mrrrl

MIS
Dec 26, 2001
179
US
I built a test web app that connects to a SQL DB and displays certain items. I used pubs database to test. I set up the Data Connection using Server Explorer (tested good), then pulled the authors table in to the form. This set up the SqlConnection and the SqlDataAdapter. I created the DataSet. I then put on the form a Data Grid and set up the DataSource and DataMember to point to the DataSet and the table authors. I then put in this code to load the Data Grid.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
DataSet31.Clear()
SqlDataAdapter1.Fill(DataSet31)
End Sub

When I run it, the web page shows up but no data from the DB. The Data Grid does not show up at all.

Now, I do the exact same thing but this time using a VB.Net project (not web based) and it works just fine.

Any ideas as tho what may be wrong? I believe it should work the same for both the web based app and a normal VB app.

TIA
 
OK, I figured it out. Have to add this line:

DataGrid1.DataBind()

to this code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
DataSet31.Clear()
SqlDataAdapter1.Fill(DataSet31)
DataGrid1.DataBind()
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top