Hello
I'm trying to populate a DataGridView with a stored procedure using VB.NET.
The query I need to use is within a Access 2007 datadase. When I run it in Access it is showing data but the DataGridView displays nothing.
The code I'm using to populate the DataGridView is:
------------------------------------------------------------------------------
'Create connection object.
CConnection = New CDatabaseConnec tion
With CConnection
.NewMSAccessCon nection(strFile Path)
.OpenDBConnecti on()
End With
'Initialize a new instance of the OleDbCommand class.
objCommand = New OleDbCommand
'Set command object properties.
objCommand.Comm andText = "usp_AccessQuer y"
objCommand.Comm andType = CommandType.Sto redProcedure
objCommand.Conn ection = CConnection.obj Connection
'Initialize a new instance of the Adapter class.
objDataAdapter = New OleDbDataAdapte r
'Initialize a new instance of the DataSet class.
objDataSet = New DataSet
'Set the SelectCommand for the DataAdapter.
objDataAdapter. SelectCommand = objCommand
'Populate the DataSet.
objDataAdapter. Fill(objDataSet )
Me.DataGridView 1.DataSource = objDataSet
------------------------------------------------------------------------------
I tried to populate a DataGrid using the same code sequence and found I had to select the expand icon within the grid to show a list of all the query columns with headings, but no data was shown.
Any ideas as to why this is happening?
Since I'm going to be doing more of this type of programming, does anyone know of some good sites with tutorials for working with Access databases in VB.NET?
Thanks.
I'm trying to populate a DataGridView with a stored procedure using VB.NET.
The query I need to use is within a Access 2007 datadase. When I run it in Access it is showing data but the DataGridView displays nothing.
The code I'm using to populate the DataGridView is:
------------------------------------------------------------------------------
'Create connection object.
CConnection = New CDatabaseConnec tion
With CConnection
.NewMSAccessCon nection(strFile Path)
.OpenDBConnecti on()
End With
'Initialize a new instance of the OleDbCommand class.
objCommand = New OleDbCommand
'Set command object properties.
objCommand.Comm andText = "usp_AccessQuer y"
objCommand.Comm andType = CommandType.Sto redProcedure
objCommand.Conn ection = CConnection.obj Connection
'Initialize a new instance of the Adapter class.
objDataAdapter = New OleDbDataAdapte r
'Initialize a new instance of the DataSet class.
objDataSet = New DataSet
'Set the SelectCommand for the DataAdapter.
objDataAdapter. SelectCommand = objCommand
'Populate the DataSet.
objDataAdapter. Fill(objDataSet )
Me.DataGridView 1.DataSource = objDataSet
------------------------------------------------------------------------------
I tried to populate a DataGrid using the same code sequence and found I had to select the expand icon within the grid to show a list of all the query columns with headings, but no data was shown.
Any ideas as to why this is happening?
Since I'm going to be doing more of this type of programming, does anyone know of some good sites with tutorials for working with Access databases in VB.NET?
Thanks.
Comment