GO is not a SQL statement per se. It is a T_SQL extension that indicates the
end of a batch. This means that you cannot use it in the way you are
attempting to.
Because the USE statement must be in a batch on it's own, you need to
execute it seperately.
rs.Execute("use mydb")
sql = "select * from mytb"
rs.open sql,...
Remember that the target database you set with the USE statement will remain
in force until you change it or the connection is closed, whichever happens
first.
> hi, can i do this in ado:
>
[quoted text clipped - 10 lines]
>
> Please advice.
js - 29 Apr 2005 14:35 GMT
Thanks Stephany,
This works too:
>> sql = "SET nocount on "
>> sql = sql & " EXEC('use mydb')"
>> sql = sql & " select * from mytb"
>> rs.open sql,...
> GO is not a SQL statement per se. It is a T_SQL extension that indicates
> the end of a batch. This means that you cannot use it in the way you are
[quoted text clipped - 27 lines]
>>
>> Please advice.