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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fundamental Question: How do I "hook up" a DataGrid with SQL Conn.? 1

Status
Not open for further replies.

HerbAndEdnaWeinstein

Technical User
Apr 30, 2003
104
US
Hi,

I'm brand new to .NET and to programmatic data access in general.

Using the Form Designer, I managed to add an SQL Connection, an SQL Data Adapter, and a datagrid to my form.

I've specified a basic select query to select all of the contents of an SQL table. As a basic exercise, I'm just trying to get the results of my query to display in the DataGrid.

I'm sure this is quite simple, but how do I get the data to display? Does it have something to do with specifying the DataSource for my DataGrid?

Thanks for any help!
hw


 
make sure the data adapters select command property was filled, make a new datatable. Use the fill methid of the dataadapter and that set the datasource property of the grid equal to the datasource.

lookup some of the walkthroughs of microsoft to get a nice start


The gap between theory and practice is not as wide in theory as it is in practice.
 
TerraSamba:

Thanks for replying. Following the walkthroughs, I got my dataset populated and I can successfully preview the data.

When the form loads, I can see the empty schema from my dataset in the datagrid.

However, when I try to fill the data using a button, the form crashes with a "system error".

Here's the button code:
***********************************************************
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
DataSet11.Clear()
SqlDataAdapter1.Fill(DataSet11._tester0)
End Sub
***********************************************************

"Dataset11" is the name of the dataset, and "_tester0" is the name of the SQL table I'm querying.

Thanks for any hints!
hw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top