Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2004, 01:23 PM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default OLEDB connection string variation

I am developing a small website and am having difficulty connecting to an Access database in an administration page where I want password protection. I have used the following code to access the page, which is done successfully. It provides True if found or False if RS.EOF is reached

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
Set Con = Server.CreateObject( "ADODB.Connection" )
  Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & server.mappath("/i/impact/data.mdb")
'Response.Write "Source=" & server.mappath("/i/impact/data.mdb") & "<br>"
    strSQL = "Select * FROM Account " &_
    "WHERE Name='" & username & "' " &_
    "AND Password='" & password & "'"

SET RS = Con.Execute( strSQL )

If NOT RS.EOF Then

do something like expose connections to other pages

End If
Set RS = nothing
Con.Close
Set Con = nothing
End If

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

however when it comes to editing the passwords used an error is generated saying that I require an updateable query?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If newpassword = confnewpassword Then
   If (thisusername = username) and (password = pword) Then ' where username & pword is passed from the previous page

   Set Con = Server.CreateObject( "ADODB.Connection" )
   Con.Open = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & server.mappath("/i/impact/data.mdb")

' Con.Open = OLE-DB("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & server.mappath("/i/impact/data.mdb"))
'Response.Write "Source=" & server.mappath("/i/impact/data.mdb") & "<br>"

      sqlString = "UPDATE Account " &_
          "SET password='" & newpassword & "'" &_
          " WHERE name='" & thisusername & "'"

'Response.Write "SqlString=" & sqlString & "<br>"
      Con.Execute sqlString
      Response.Write "Your changes have been successfully writen"
    End If
  Else%>
        <p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;
        You have not confirmed your new password Correctly</b><p>
<%End If
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have approached my server provider who has given me a different connection string used on this server:
OLE-DB("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=path to database.mdb;");

This doesn't work on my computer, however I have added it to my .asp file and uploaded it onto the server, there I have received error messages which reduced the code to:

OLE-DB("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=path to database.mdb")

Now the error message received is very unfourthcoming and reads: HTTP 500 - Internal server error Internet Explorer

Has anyone seen this form of OLEDB connection string before and does anyone know how to make it work?

 
Old October 18th, 2004, 02:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Edward,

Could this be a security error? That is, is your Web server allowed to write to the folder where the database resides?

To find out, try this:

First, change the settings for your browser so you see the real error message:

http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=264

Next, change your Connection string back to how it was as it looked pretty good to me. For more details on Access / Jet connections, look here:

http://www.able-consulting.com/MDAC/...orMicrosoftJet

Then run the page. If you get an error like 80004005, take a look here:
http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=263 and here: http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=290

If all this doesn't help, can you post the error you get?


HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 29th, 2004, 07:25 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, I have adjusted my browser as suggested to remove 'Friendly Error' reports from the server and have now got the message below:

New Error message:
Microsoft JET Database Engine error '80040e14'

Syntax error in UPDATE statement.

/12cooperdrive/revisePassword.asp, line 38

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have further adjusted my .asp file editing out the Execute command and reading instead the response.write sqlString which would have been processed, to me it looks OK so the problem is most likely to be as you suggest a server security issue.
I will take this up with my server provider for comment and report back the outcome.

revised code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
If not confnewpassword = " " Then
 If newpassword = confnewpassword Then
   If (thisusername = username) and (password = pword) Then

   Set Con = Server.CreateObject( "ADODB.Connection" )
      Con.Open = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & server.mappath("/i/impact/data.mdb")
' Con.Open "aqmsDSN"
' Con.Open = OLE-DB("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & server.mappath("/i/impact/data.mdb"))
'Response.Write "Source=" & server.mappath("/i/impact/data.mdb") & "<br>"

      sqlString = "UPDATE Account " &_
                  "SET password='" & newpassword & "'" &_
                  " WHERE name='" & thisusername & "'"

Response.Write "SqlString=" & sqlString & "<br>"
' Con.Execute sqlString
      Response.Write "Your changes have been successfully writen"
    End If
  Else%>
        <p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;
        You have not confirmed your new password Correctly</b><p>
<%End If
End If

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Revised page revisepassword.asp (29th October)
returns: SqlString=UPDATE Account SET password='Richard' WHERE name='Edward Stephen'

Many thanks Imar - you are unique in so far that you are never put off and always come back with a solution.

Edward

 
Old October 30th, 2004, 12:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

PASSOWRD is a reserved keyword. So enclose that within []s
Code:
UPDATE [Account] SET [password]='Richard' WHERE [name]='Edward Stephen'
This should solve the problem.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old November 2nd, 2004, 10:26 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar & Vijay G, Your solution is correct. I have received a list of Access DB reserved words from my Server Provider giving the same information, I have added the table name to the field name ie. AccountName & AccountPassword which is achieving the same result. It is now working - many thanks to you both.
Cheers!

Edward.






Similar Threads
Thread Thread Starter Forum Replies Last Post
webpart using sonofsmartpart and OLedb Connection aymane SharePoint Development 0 June 20th, 2006 09:59 AM
Missing parameter in Jet OLEDB connection OldCoder ASP.NET 1.0 and 1.1 Professional 2 April 21st, 2006 11:29 PM
Deploying CR 8.5 using (DSN less) OLEDB Connection ashu_from_india Crystal Reports 0 July 10th, 2005 09:23 AM
OleDb Connection string bimal General .NET 1 January 3rd, 2005 03:02 PM
OLEDB Connection Dialog Kep C# 4 December 15th, 2004 06:10 PM





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