Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 14th, 2004, 01:14 PM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default Recordset Problems

I'm trying to open up a database for a work project and do several things with it. I believe that once I actually get the database to open and make a record set I can handle it but so far I keep having problems. Here's the code:

<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Testing</TITLE>
</HEAD>
<BODY>

<%
    Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
    adOpenForwardOnly = 0
    adLockReadOnly = 1
    adCmdTable = 2

    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set objRS = Server.CreateObject("ADODB.Recordset")

    Dim strDatabaseType
    strDatabaseType = "Access"

    If strDatabaseType = "Access" Then
        objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                 "Data Source = c:\inetpub\database\ftp.mdb;" & _
                 "Persist Security Info=False"
    Else
        objConn.Open "Provider=SQLOLEDB;Persist Security Info=False;" & _
                 "USER ID=;Initial Catalog=Password;" & _
                 "Initial File Name=c:\inetpub\database\ftp.mdb;"
    End If

    objRS.Open "PASSWORD", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable

    dim strSel
    strSel = "SELECT [Password] FROM Password WHERE [Password] = pillow"
    objRS.Open strSel

    While Not objRS.EOF
        Response.Write objRS("PASSWORD") & "<BR>"
        objRS.MoveNext
    Wend

    objRS.Close
    objConn.Close
    Set objRS = Nothing
    Set objConn = Nothing
%>
</BODY>
</HTML>

The error is: Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in FROM clause.
/adamstuff/test.asp, line 31

Reply With Quote
  #2 (permalink)  
Old July 14th, 2004, 02:28 PM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

*Bump*

Reply With Quote
  #3 (permalink)  
Old July 14th, 2004, 03:07 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Does *Bump* mean you figured it out?

[Password] = 'pillow'
NOT
[Password] = pillow

Reply With Quote
  #4 (permalink)  
Old July 14th, 2004, 03:31 PM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

No, bump as in bump it to the top of the list to get more people to look at it. And I changed what you said but that still isn't the problem. Its thinking that:
    objRS.Open "PASSWORD", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable

has a from clause in it somewhere.

Reply With Quote
  #5 (permalink)  
Old July 14th, 2004, 03:58 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Just curious, you have a field called 'Password' in a table called 'Password' is that correct? Can you try this out and see what happens?

cn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Password.mdb"

set rs = server.createobject("adodb.recordset")
sql = "select Password from Password where Password = 'Pillow'"
rs.open sql, cn
if not rs.eof then
    do while not rs.eof
    response.write rs("Password") & "<br>"
    rs.movenext
    loop
end if
rs.close
set rs = nothing
Reply With Quote
  #6 (permalink)  
Old July 14th, 2004, 04:11 PM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

I had to change your stuff to this:

    dim cn, sql, rs
    cn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\inetpub\database\ftp.mdb"
    set rs = server.createobject("adodb.recordset")
    sql = "select Password from Password where Password = 'Pillow'"
    rs.open sql, cn
    if not rs.eof then
        do while not rs.eof
        response.write rs("Password") & "<br>"
        rs.movenext
        loop
    end if
    rs.close
    set rs = nothing


The password.mdb is not the database name so it didn't exist so I changed it. Yes there is a password field in a password table. I didn't design the database and don't have access to change it but no, I still got the same error with the from clause.

Reply With Quote
  #7 (permalink)  
Old July 14th, 2004, 04:51 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is weird. I created the same scenario and get the same error. I changed the table name and the recordset worked. I wonder if the word 'Password' is a reserved (or restricted) word when it comes to database tables.

Reply With Quote
  #8 (permalink)  
Old July 15th, 2004, 06:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, it is a RESERVED word in either ADO, OLEDB. Check out this page.
Scenario 1 - Syntax error in FROM clause

You have no other go, than changing the names for both the table and column(which I would suggest) or atleast either of that names.

When you execute a "SELECT PASSWORD FROM PASSWORD" directly on your database, that would result all the rows with password. But when you do that using ADO or OLEDB, you would get this error.

Hope that explains.
cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #9 (permalink)  
Old July 15th, 2004, 09:15 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Well, I appreciate the help guys but I have a problem. My network admin says they can't change either of the names. He said that using square brackets around it would solve the problem and he has run into it before but gotten around it. It doesn't seem to fix the problem for me though. Any ideas? Thanks.

Reply With Quote
  #10 (permalink)  
Old July 15th, 2004, 09:26 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Thanks guys, I got it working.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset Problems toosuave PHP Databases 1 August 27th, 2006 09:03 PM
DAO Recordset Problems SteveH Access VBA 1 October 5th, 2005 05:39 PM
recordset problems p2ptolu Classic ASP Databases 0 July 9th, 2005 07:54 AM
Problems importing Excel into ADO.Net recordset AshleyC ADO.NET 0 February 22nd, 2005 05:56 AM
Recordset Problems... bbhill SQL Language 2 October 16th, 2003 05:22 PM



All times are GMT -4. The time now is 07:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.