connectivity through DSN

D

David

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
 
B

Bob Barrows

David said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top