Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / April 2005



Tip: Looking for answers? Try searching our database.

query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
js - 28 Apr 2005 20:10 GMT
hi, can i do this in ado:

dim rs
dim sql
sql = "SET nocount on "
sql = sql & " use mydb"
sql = sql & " go"
sql = sql & " select * from mytb"
rs.open sql,...

But I got error:
Line 3: Incorrect syntax near 'GO'.

Please advice.
Stephany Young - 29 Apr 2005 02:11 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.