-1

please check this code
and tell me what is the problem with this .....
i get error"operation is not allowed when the object is open"

dim conn as new adodb.connection
private sub commandbutton1_click()
conn.connectionstring="dsn=localhost;uid=root;pwd=root;"
conn.open
dim cmd as new adodb.command
cmd.commandtext="select sname from stu"
cmd.commandtype=adcmdtext
cmd.activeconnection= conn
end sub
Votes + Comments
No one here to do your home work.
4
Contributors
3
Replies
8
Views
1 Year
Discussion Span
Last Post by AleMonteiro
0

It means that when you tried to do

conn.Open()

the database connection was already open. Because you declared conn globally it will retain its connection state between ececutions of your sub. In any case, your sub appears to serve no purpose other than setting the connection string. You declare and initialize cmd but don't do anything with it so what is the point?

Edited by Reverend Jim

0

I am not sure about the intension of the OP. He puts some codes to show his efforts about his job and hopes any one can help him to do his home work.

This topic has been dead for over six months. 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.