connectivity through DSN

Discussion in 'ASP General' started by David, Nov 10, 2003.

  1. David

    David Guest

    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
     
    David, Nov 10, 2003
    #1
    1. Advertising

  2. David

    Bob Barrows Guest

    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"
     
    Bob Barrows, Nov 10, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Niks

    Database Connectivity using DSN

    Niks, Dec 22, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    10,862
    Kevin Spencer
    Jan 12, 2004
  2. Arun K

    Database Connectivity using DSN

    Arun K, Dec 22, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Natty Gur
    Dec 23, 2003
  3. Kevin Spencer

    Re: Creating DSN through Code

    Kevin Spencer, Jul 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    Kevin Spencer
    Jul 27, 2004
  4. Neo
    Replies:
    0
    Views:
    411
  5. Arpan

    System DSN Faster Than File DSN!

    Arpan, Jun 26, 2005, in forum: ASP General
    Replies:
    7
    Views:
    270
Loading...

Share This Page