Please could anyone advise why the following code errors:-
Dim myConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data\PicountsData.mdb")
Dim myCommand As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand()
Dim dr As System.Data.OleDb.OleDbDataReader
myConnection.Open()
myCommand.Connection = myConnection
myCommand = New System.Data.OleDb.OleDbCommand("SELECT * from tblStockCounts WHERE STOCKCODE = '" & oStockItem.Code & "'")
dr = myCommand.ExecuteReader
The error is :-
ExecuteReader: Connection property has not been initialized.
Thanks