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
Santanu.Das commented: No one here to do your home work. -1

Recommended Answers

All 3 Replies

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?

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 really looks like could be in a homework text book, lol. Hope not btw.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.