Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > connectivity through DSN

Reply
Thread Tools

connectivity through DSN

 
 
David
Guest
Posts: n/a
 
      11-10-2003
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
 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      11-10-2003
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"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to launch DSN Configuration Box through code? Neo ASP .Net 0 01-18-2006 06:31 PM
System DSN Faster Than File DSN! Arpan ASP General 7 07-02-2005 04:01 PM
Re: Creating DSN through Code Kevin Spencer ASP .Net 0 07-27-2004 08:26 PM
Database Connectivity using DSN Niks ASP .Net 3 01-12-2004 02:12 PM
Database Connectivity using DSN Arun K ASP .Net 1 12-23-2003 08:00 AM



Advertisments