Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jun 29, 2000

Encase Query Names in Brackets to Avoid ADO/Jet Errors

While using OLE DB Provider for Jet to manage Access databases through ADO from VB, follow this tip to help you access a query defined in your database. If the query name contains blank characters (ASCII code 32), supply this code, enclosing the name in brackets:
 
'To access the query by the 
'Recordset object's Open method:
rs.Open "[Name with blanks]", _ 'Etc.

'To access the query by a Command object:
cm.CommandText = "[Name with blanks]"
If you don't, your program will show a runtime error when you try to open the recordset. The OLE DB Provider for Jet databases interprets the supplied string as a SQL statement, which doesn't match that language syntax. Specifying different values for the Command object's CommandType property—or specifying different values on the Options argument when invoking the recordset's Open method—doesn't fix the problem. You must use the brackets.
Leonardo Bosi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date