Avatar of Petermcg001
Petermcg001
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

ExecuteReader error

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
Visual Basic.NETVisual Basic Classic

Avatar of undefined
Last Comment
Petermcg001

8/22/2022 - Mon