Data Reader problem

fkheng

Well-known member
Joined
May 8, 2003
Messages
155
Location
Malaysia
initialiseDB()
sqlStr = "SELECT * FROM LoginTable"
command = New OleDbCommand()
command.CommandText = sqlStr
command.Connection = conn
reader = command.ExecuteReader()


my code halts at reader = command.executereader, and the error i get is that i am carrying out an invalid operation

the conn value i assign to command.connection is initialised in a function which i call called initialiseDB

i do not know why it stops here, can someone help me out?
 
oh yah, one more thing, the function is located in a module, where i declare the conn value as public, so i assume that my form can make use of the conn variable with no problems? am i wrong here? or must i pass back the conn value to the function caller and assign it to a local variable?
 
You need to make sure the connection is open before executing ExecuteReader(), and I also dont see any place where reader is declared. Oh.. and make sure LoginTable exists in the db that your connection connects to. :)
 
Back
Top