Click to See Complete Forum and Search --> : Cannot Open RecordSet


kuvo
August 16th, 1999, 09:55 AM
Hi,
why do I get this error, What can I do ?
Thanks

cmd.CommandType = adCmdText
Set cmd.ActiveConnection = cnnMyConnection
cmd.CommandText = "Create Table MyTable "
Set rsTable = cmd.Execute


rsTable.AddNew
----ERROR: Object is closed ?????

rsTable.Fields("Name") = "Kathy"
rsTable.Fields("City") = "Montreal"

Lothar Haensler
August 16th, 1999, 10:09 AM
IMHO this should rather look like this:

cmd.CommandType = adCmdText
set cmd.ActiveConnection = cnnMyConnection
cmd.CommandText = "Create Table MyTable "
' create the table
cmd.Execute
' now open a recordset
cmd.commandtext = "select * from mytable"
set rsTable = cmd.Execute
...

kuvo
August 16th, 1999, 10:31 AM
At the second .Execute :
I've got error "Could not find MyTable"

Looks like the first Excecute does not work

Lothar Haensler
August 16th, 1999, 11:02 AM
well, I thought that your statement was meant as an example.
Of course "Create table mytable" is not valid SQL. You need to specify the fields of your table as in:
create table mytable(firstfield char(20))

Also, check all errors that you get when executing a statement.