0

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 by mitch_oso

3
Contributors
6
Replies
7
Views
4 Years
Discussion Span
Last Post by thewilf
0

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

0

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

0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.