SEANWYATT
asked on
DataGridView data binding (ADO.NET 2.0)
I would like to use the results of a stored procedure to fill a datagridview. I am not using the Data Set IDE and created the Stored Procedure objects manually. I added a blank datagridview control to the form named dgPartInfo but don't know where to go from here:
Dim cmdGetPartInfo As New SqlCommand("SW_GET_PART_BA SICS", dbConn) ' gets header info from part table
cmdGetPartInfo.CommandType = CommandType.StoredProcedur e
cmdGetPartInfo.Parameters. AddWithVal ue("@PART_ ID", strPartID)
Dim PartReader As SqlDataReader = cmdGetPartInfo.ExecuteRead er
dgPartInfo.DataSource = PartReader
I am moving from mostly VB6 experience to .NET 2.0 so am not very familiar with the datagrid and datagrid view controls or the difference between them. All the documantation I can find only shows how to poulate a grid by dragging items from the Data Set IDE.
Thanks,
Dim cmdGetPartInfo As New SqlCommand("SW_GET_PART_BA
cmdGetPartInfo.CommandType
cmdGetPartInfo.Parameters.
Dim PartReader As SqlDataReader = cmdGetPartInfo.ExecuteRead
dgPartInfo.DataSource = PartReader
I am moving from mostly VB6 experience to .NET 2.0 so am not very familiar with the datagrid and datagrid view controls or the difference between them. All the documantation I can find only shows how to poulate a grid by dragging items from the Data Set IDE.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataGridView1.DataSource = categories.Tables("Categor ies")
the datasource for your datagridview needs to be a datatable/dataview not a datareader.
stealing from vadim's example:
dgpartinfo.datasource = categories.tables("categor ies")
stealing from vadim's example:
dgpartinfo.datasource = categories.tables("categor
ASKER
OK Thanks. I was trying to do it without the table defiined but now it makes sense.
I appreciate the quick response.
I appreciate the quick response.
ASKER