Hi Everyone,

I have this problem whit my code : ExecuteReader: Connection Property has not been initialized
and i don't know why

This is my code:

Dim maximo As Integer
        Try
            oConn = New OleDb.OleDbConnection(con)
            oConn.Open() ' abrimos la base de datos
            oComn = New OleDb.OleDbCommand("Select ID_ISSUE From ISSUE")
            oRsRead = oComn.ExecuteReader() 'para leer la base de datos
            While oRsRead.Read() ' ciclo para leer la base de datos
                maximo = ("ID_ISSUE")
            End While
            oConn.Close() 'se cierra la base

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        MsgBox(maximo)


        MessageBox.Show(ex.Message)
    End Try
    MsgBox(maximo)

Thanks

Edited 4 Years Ago by mitch_oso

Hi Everyone,

I have this problem whit my code : ExecuteReader: Connection Property has not been initialized
and i don't know why

This is my code:

Dim maximo As Integer
        Try
            oConn = New OleDb.OleDbConnection(con)
            oConn.Open() ' abrimos la base de datos
            oComn = New OleDb.OleDbCommand("Select ID_ISSUE From ISSUE")
            oRsRead = oComn.ExecuteReader() 'para leer la base de datos
            While oRsRead.Read() ' ciclo para leer la base de datos
                maximo = ("ID_ISSUE")
            End While
            oConn.Close() 'se cierra la base

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        MsgBox(maximo)


        MessageBox.Show(ex.Message)
    End Try
    MsgBox(maximo)

Thanks

i don't understand you but not is this: oComn = New OleDb.OleDbCommand

Dim oConn As New OleDb.OleDbConnection("PROVIDER=xxx;DATA SOURCE=xxx")
oComm = New OleDb.OleDbCommand(Your SQL Command Here, oConn)

oRsRead = oComm.ExecuteReader

Hope this helps, you need to include the connection in the command as above.

Cheers
Will

Thank you so much
i didn't put insede teh comand ", oConn"
:P
thanks

This question has already been answered. Start a new discussion instead.