469,924 Members | 1,389 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

connectivity through DSN

Hi
I have written few line codes but puzzling me lot giving
errors...
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "wedding"
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from Group"
rs.open sql, Conn ' Gives error this statement
Set rs = Nothing
Conn.close
Set Conn = Nothing

Connection is established successfully and recordset is
also created without any problem
but when it executes rs.open line it gives me error
tht
"SYNTAX ERROR NEAR FROM CLAUSE"
I cant understand whats going on...
Please help me...
Thanx in advance...
David
Jul 19 '05 #1
1 1390
David wrote:
Hi
I have written few line codes but puzzling me lot giving
errors...
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "wedding"
Don't use a DSN. Use the native OLEDB provider for your database. See here
for an example: www.able-consulting.com/ado_conn.htm. Avoid the ODBC section
and find the examples for the OLEDB provider for whatever your database is
(and in the future, always tell us what database you are using when asking a
database-related question).
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from Group"
rs.open sql, Conn ' Gives error this statement
Set rs = Nothing
Conn.close
Set Conn = Nothing

Connection is established successfully and recordset is
also created without any problem
but when it executes rs.open line it gives me error
tht
"SYNTAX ERROR NEAR FROM CLAUSE"
I cant understand whats going on...
Please help me...
Thanx in advance...
David


"Group" is a reserved word. It is a keyword in all SQL languages that I know
of (think "Group By"). It is a bad idea to use a reserved word for a column
or table name. I stronly recommend that you change the name of this table to
a non-reserved word (such as "Groups"). If you cannot change the name of the
table for some reason, then you will need to surround it with brackets []
when using it in a query: Select ... From [Group]. See here for a list of
reserved words: http://www.aspfaq.com/show.asp?id=2080

I also suggest you avoid using "select * " in production code. Always
explicitly list the fields you wish your query to retun, even if you wish it
to return all the fields in your table. This is simply good coding practice,
and can avoid performance problems.

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Axel Dachtler | last post: by
3 posts views Thread by Omegamon | last post: by
3 posts views Thread by junaid | last post: by
3 posts views Thread by Niks | last post: by
1 post views Thread by Darren McDowell via .NET 247 | last post: by
1 post views Thread by ohs | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.