Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP 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 January 28th, 2005, 11:47 AM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Another ASP/Access Problem - HELP!

Hello All, I am new to working with Access DB's (believe it or not) and I have developed a application that for some reason will not run on my PC. I am trying to access my login page and get the follwing error:

Error Type:
Microsoft JET Database Engine (0x80004005)
Could not find file 'C:\WINDOWS\system32\site.mdb'.
/ASPLogin/dbconnection.inc, line 6

I have checked my db connection:

<%
Set adoCon = Server.CreateObject("ADODB.Connection")

src = "site.mdb"
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
adoCon.Open sConnStr

'Set an active connection to the Connection object using DSN
'adoCon.Open "DSN=ASPLOGIN"
%>

The Access DB is in the same directory as my ASP pages, but they will not come up.



Any suggestions?????????



Reply With Quote
  #2 (permalink)  
Old January 28th, 2005, 12:05 PM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops, I believe I fixed it by changing me code to:

<%
Set adoCon = Server.CreateObject("ADODB.Connection")

src = "C:\Inetpub\wwwroot\ASPlogin\site.mdb"
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
adoCon.Open(Server.Mappath("C:\Inetpub\wwwroot\ASP login\site.mdb"))

'Set an active connection to the Connection object using DSN
'adoCon.Open "DSN=ASPLOGIN"
%>

But now I am having another problem. I created a form page that writes to an Access DB. Everything seems to work fine with the form. I enter the information and press submit and it takes me to my "thank you" page.

However, the form is not writing to my MS Access DB. Any Suggestions???? I promise... this one I cannot answer myself!

Thanks!


Reply With Quote
  #3 (permalink)  
Old January 28th, 2005, 12:48 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Neil

Server.Mappath("C:\Inetpub\wwwroot\ASPlogin\site.m db")

doesn't make much sense. Server.MapPath is used to transform a virtual path into a physical path. Usually, it's used like this:

Server.MapPath("/Database/site.mdb")

This converts the virtual, root path Database/site.mdb to something like c:\Inetpub\wwwroot\Database/site.mdb. Useful when you don't know the exact physical location of the folder.

To answer your other question you'll need to post some code. Maybe you're not updating the database at all, maybe you're using On Error Resume next etc.

Please post the relevant code so we can take a look.

Cheers,

Imar
Reply With Quote
  #4 (permalink)  
Old January 28th, 2005, 01:08 PM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar! I am still cleaning up the code and made your recommended modification.

Below is my ASP code for the login page. It should log the user in by writing to the Access DB:


<%@ LANGUAGE="VBSCRIPT" %>
<%Response.Buffer=TRUE%>


<%
    'Create an ADO recordset object
    Set rsSiteName = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT sitename FROM tblAdmin"

    'Open the recordset with the SQL query
    rsSiteName.Open strSQL, adoCon

    Response.Write ("<title>")
    Response.Write (rsSiteName("sitename"))
    Response.Write ("</title>")

    Set rsSiteName = Nothing
%>

<script language="JavaScript">
    function setFocus()
    {
      Login.txtUserName.focus();
    }
  </script>



<body onload="setFocus();">

<br>
<br>
<%
If Request.querystring("mode") = "suspend" then
Response.Write ("<center>Username is currently suspended</center><br><br>")
End If

If Request.querystring("mode") = "once" then
Response.Write ("<center>Username is currently logged in</center><br><br>")
End If

If Request.querystring("mode") = "invalid" then
Response.Write ("<center>Invalid username or password. Please try again.</center><br><br>")
End If
%>
<form name="Login" method="post" action="login.asp">
  <table width="320" border="0" align="center" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC">
    <tr>
      <td align="right" height="47" valign="bottom" width="94">User name: </td>
      <td height="47" valign="bottom" width="172">
        <input type="text" name="txtUserName">
      </td>
    </tr>
    <tr>
      <td align="right" width="94">Password: </td>
      <td width="172">
        <input type="password" name="txtUserPass">
      </td>
    </tr>
    <tr>
      <td align="right" height="44" width="94">&nbsp;</td>
      <td height="44" width="172">
        <input type='image' src='images/forward_16.gif' name='Submit' value='Enter' alt='Enter'>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;
        <input type='image' src='images/cancel_16.gif' name='Reset' value='Reset' alt='Reset'>
      </td>
    </tr>

<%
    'Create an ADO recordset object
    Set rsLostPassword = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT lostpassword FROM tblAdmin"

    'Open the recordset with the SQL query
    rsLostPassword.Open strSQL, adoCon

    If rsLostPassword("lostpassword") = 1 then
        Response.Write ("<tr><td align='right' height='44' width='94'>&nbsp;</td><td>Get lost password &nbsp;<a href=password.asp?mode=enter>here</a></td></tr>")
    End If

    Set rsLostPassword = Nothing

%>
<%


    'Create an ADO recordset object
    Set rsRegister = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT register FROM tblAdmin"

    'Open the recordset with the SQL query
    rsRegister.Open strSQL, adoCon

    If rsRegister("register") = 1 then
        Response.write ("<tr><td align='right' height='44' width='94'>&nbsp;</td><td>Register for an account &nbsp;<a href=register.asp?mode=new>here</a></td></tr>")
    End If

    Set rsRegister = Nothing
    Set adoCon = Nothing

%>
  </table>
</form>


</body>

Thanks for taking a look!

Neil


Reply With Quote
  #5 (permalink)  
Old January 28th, 2005, 06:34 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Can you explain where you expect the database to be updated (where in the code, that is)? What is the page supposed to do?

All I see is SELECT code, that gets records from the database....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #6 (permalink)  
Old January 31st, 2005, 11:18 AM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar, this page will query the DB to verify that the user is registered via a users table, which will distinguish them between a regular user and an admin. The query is supposed to write to the database and record the user as active. This in turn will redirect them to the appropiate home page (ie user or admin). The problem I am having is that it is not writing to the DB, so the next page just stays blank.

I ran some tests over the weekend and it seems to execute on my laptop, but not my PC. Both machines are using Windows XP, with IIS V5.1.

I am not sure what the problem is???? :(

Neil

Reply With Quote
  #7 (permalink)  
Old January 31st, 2005, 02:42 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

But it looks like another page is involved, no? The code you have posted does not update a database anywhere, so there must be another(include??) file that does the insert/update, right?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #8 (permalink)  
Old January 31st, 2005, 03:06 PM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, another page is involved. I should have included it earlier:



<%
'Dimension variables
Dim rsCheckUser 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim strUserName 'Holds the user name

'Initalise the strUserName variable
strUserName = Request.Form("txtUserName")

'Create an ADO recordset object
Set rsCheckUser = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT password, ID, username, admin, suspend FROM tblUsers WHERE username ='" & strUserName & "'"

'Open the recordset with the SQL query
rsCheckUser.Open strSQL, adoCon

strActiveUser = "Select * From Active_Users Where User_ID='" & strUserName & "'"
Set rs1 = adoCon.Execute (strActiveUser)

'If the recordset finds a record for the username entered then read in the password for the user
If NOT rsCheckUser.EOF Then

    If NOT rs1.EOF Then
        Response.Redirect ("default.asp?mode=once")
    'Read in the password for the user from the database
    Else If md5(Request.Form("txtUserPass")) = rsCheckUser("password") Then

         If rsCheckUser("suspend") = 0 Then
         'Write the HTML to display the current record in the recordset

            Session("userGood") = True
            Session("userID") = rsCheckUser("ID")
            Session("userName") = rsCheckUser("username")
            Session("userAdmin") = rsCheckUser("admin")
                        strUsername = rsCheckUser("username")
                        strLoginSql = "UPDATE tblusers SET last_login='" & now() & "' WHERE username ='" & strUsername & "'"
                        adoCon.execute (strLoginSql)

         Else
         Response.Redirect("default.asp?mode=suspend")
         End If


    'Reset server objects
    rsCheckUser.Close
    Set rsCheckUser = Nothing
    Set adoCon = Nothing

    'Redirect to the authorised user page and send the users name
        Response.Redirect"main.asp"

    End If
    End If
End If





'Reset server objects
rsCheckUser.Close
Set rsCheckUser = Nothing
Set adoCon = Nothing

'If the script is still running then the user must not be authorised
Session("userGood") = False

'Redirect to the unautorised user page
Response.Redirect"default.asp?mode=invalid"
%>

Reply With Quote
  #9 (permalink)  
Old January 31st, 2005, 03:16 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Ah, I see.

Unfortunately, I cannot see a clear reason for an error, so I think you'll need to do some debugging.

What happens when you add some Response.Write and Response.End statements to the page you just posted? Does it get to the code you expect it to reach? Maybe there is a difference in the MD5 functionality? Maybe Now() is in american date format on one server and English / Swedish / Whatever on the other.

There are too many potential problem areas, so I guess you'll need to figure out where it breaks first....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #10 (permalink)  
Old February 3rd, 2005, 09:52 AM
Registered User
 
Join Date: Jan 2005
Location: Columbus, Ohio, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

[b]Thanks for the feedback Imar. I am still working on it. All my other ASP pages work fine. It is only the ones that have database connections that are not executing.

I am thinking that it may have something to do with the ODBC driver. I am not familiar enough to say what it is specifically. I remember reading in one of the threads here, that the Microsoft Jet OLE DB or ODBC driver had to be purchased from Microsoft, or ASP pages had to be converted to ASP.NET.

Any other tips would be a great help.

Thanks![b]

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
date field problem in access asp varia_mahesh Classic ASP Basics 1 June 6th, 2007 07:02 PM
date field problem access asp varia_mahesh Access ASP 0 June 6th, 2007 08:33 AM
asp / access mailing list database problem srobert1 Access ASP 1 May 2nd, 2005 06:11 PM
problem in select statement in ASP-ACCESS s.abraham ASP.NET 1.0 and 1.1 Basics 2 March 24th, 2005 02:31 PM
Problem with SQL (MS-Access) and ASP DaPrince Access ASP 4 August 14th, 2004 08:11 AM



All times are GMT -4. The time now is 03:46 PM.


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