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()
dim cmd as new adodb.command
cmd.commandtext="select sname from stu"
cmd.activeconnection= conn
end sub
commented: No one here to do your home work. -1

It means that when you tried to do


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.