PDA

View Full Version : questions with .mdb files


dw5304
02-22-2005, 07:38 PM
I have a microsoft data bace file that works with a log in or is supposed to but it gives me an error of
"Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xf0 Thread 0xa08 DBC 0xcdb87d4 Jet'.

/dw5304/loginasp/members.asp, line 60 "


this did work the other day and now it dosent

im confused?


this is the code on line 63
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("loginasp.mdb")

is there somthing wrong with my code or is it a defective data bace?

miranda
02-23-2005, 07:09 AM
Did you create the database object before you tried to open it? show all the asp code leading up to and including that line. And we can probably help you.

dw5304
02-24-2005, 01:20 AM
ok here it goes
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>login</title>
</head>

<body bgcolor="#EAF1FF">
<p>if the home page does not load hit the refresh</p>
<%
'Dimension variables
Dim adoCon 'holds the database object
Dim rsCheck 'check
Dim strSQL 'Query the database
Dim Membert 'member type
Membert = 1

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("loginasp.mdb")


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


'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Membert, tblUsers.Header from tblUsers where Membert = '" & Membert & "'"

'Open the recordset with the SQL query
rsCheck.Open strSQL, adoCon
%>

<%If rsCheck.EOF Then%>

please go to setup.
<%else%>
<%IF rsCheck("Header") = "1" then%>
<!-- #INCLUDE FILE="header.inc" -->
<%'Reset server objects
rsCheck.Close
Set rsCheck = Nothing
Set adoCon = Nothing
%>
<%end IF%>
<%end IF%>

<%IF Request.QueryString("action") = "check" then%>
<%
'Dimension variables
Dim Username
Dim Password
Username = Request.Form("Uname")
Password = Request.Form("Password")

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("loginasp.mdb")

miranda
02-24-2005, 02:13 AM
Redundant Code and is commented out and in red
unnecessary delimiters to delete are also in red
my changes are in blue

Why do you use inline coding delimiters inside a code block???? it isn't necessary and in fact is a bad idea.

also, you have request.Querystring and request.Form on the same page!!! Request.Querystring is used on form method = GET
Request.Form is used on form method POST

You have a variable listed as an integer. How is it listed in the datatable?
I am refering to the datatype of tblUsers.Membert. Is this Data Type of Text or Memo? If NOT then change your Query like so
strSQL = "SELECT tblUsers.Membert, tblUsers.Header from tblUsers where Membert = " & Membert & ""



<%OPTION EXPLICIT ' A MUST for beginners %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>login</title>
</head>

<body bgcolor="#EAF1FF">
<p>if the home page does not load hit the refresh</p>
<%
'Dimension variables
Dim adoCon 'holds the database object
Dim rsCheck 'check
Dim strSQL 'Query the database
Dim Membert 'member type
Dim DBLocation 'location of the database on the server
DBLocation = Server.MapPath("loginasp.mdb")
Response.Write DBLocation 'ensures the database is where you think it is
'compare what is printed on the string to where it is located within the
'directory structure of your website.
Membert = 1

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBLocation

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Membert, tblUsers.Header from tblUsers where Membert = '" & Membert & "'"
'Create an ADO recordset object --- open late close early
Set rsCheck = Server.CreateObject("ADODB.Recordset")

'Open the recordset with the SQL query
rsCheck.Open strSQL, adoCon
%>

<%If rsCheck.EOF Then%>
please go to setup.
<%else
If rsCheck("Header") = "1" then%>
<!-- #INCLUDE FILE="header.inc" -->
<%'Reset server objects
rsCheck.Close

'WHY???????? You are going to use this later on, so why close???
'Set rsCheck = Nothing
'Set adoCon = Nothing
End If
End If
If Request("action") = "check" then
'Dimension variables
Dim Username
Dim Password
Username = Request.Form("Uname")
Password = Request.Form("Password")

'Create an ADO connection object
'redundant code and not needed it can be reused from above.
'Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
'adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("loginasp.mdb")

ghell
02-24-2005, 04:52 PM
o.O

well you use Request() without specifying QueryString or Form

does option explicit make it any faster btw, i never bother with it .. apparently "lazyness is a virtue for a programmer".. i duno... im lazy and it works for me :thumsup:

i expect the QS and Form are used on the same page because it is one page split into several sub-pages, this would explain why the object is closed too (dont keep it open if only some subpages load it)

miranda
02-24-2005, 10:13 PM
In this instance yes, I used the request object without specifying which collection. All request object variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order:
1)QueryString
2)Form
3)Cookies
4)ClientCertificate
5)ServerVariables
If a variable with the same name exists in more than one collection, the Request object returns the first instance encountered.

As to the use of OPTION EXPLICIT this is because Prior to VB.NET users could implicitly declare their variables. (and yes in VB.NET you can turn off Option Explicit but the default is for it to be on) This creates problems though and all beginners should use it to help them. It is especially useful in debugging because it will point out typos of variables to you. Laziness is not a virtue for a programmer. Try using a variable in C++ or Java without declaring it.

I doubt that this user is at a level that he/she is comfortable using subs. Most of the code was shown as inline code. It looked to me like the user didnt realize that an object can be declared, initialised, opened, closed, reopened, closed, reopened again, closed, and on and on until it is set to nothing at which point it is removed from memory. I see so many begining programmers use multiple recordset objects on a single page where one will work.

dw5304
02-24-2005, 11:51 PM
hey sorry about this guys this is my first data base in asp so be pacent with me. Im learning as i go here. To make things worse Im not vary good in asp now any ways. been learning for about 5 weeks on my own so forgive me if i do somethings different. I know that you can use subs but havent had the time to work on it. I know more about vb.net, html, and java not asp

miranda
02-25-2005, 01:30 AM
if you are familiar with vb.net then use asp.net. ASP 3.0 is old technology and you are better off using asp.net anyway

dw5304
02-25-2005, 06:44 PM
ok thanks I will retry this in asp.net thanks for your help though