SQL Error

SQL Error

am 19.09.2005 15:46:24 von Spencer Hurst

Hi, I have currently found an ASP based website that i developed about 3
years ago and am very keen to get it up and running, it's quite a simple
site, however when i try to do anything with the database i have a
problem with the DSN (I Think).

The error i get is something like the following:
[Microsoft][ODBC Driver Manager]
Drivers SQLSetConnectAttr failed.
/homepage/takeregistration.asp line 10.

The code from which this error is obtained is:

<%@ LANGUAGE="VBSCRIPT" %>
<% pageTitle = "Login - www.schurst.co.uk" %>


<% p_userid = Request.form ("p_userid")
p_pass = Request.form ("p_pass")
p_save = Request.form ("p_save")

set spencerDB = Server.CreateObject ("ADODB.Connection")
spencerDB.Open "spencer" <<<<< LINE 10

sqlText = "select * from members where username = '" & p_userid & "'"

set userSet = spencerDB.Execute(sqlText)
if userSet.EOF then
'No such username so the recordSet is empty
Response.Redirect "/homepage/login.asp?retry=username"
else
'The username is good, now lets check the password
real_password = trim (userSet("password"))
if p_pass = real_password then
'Password is good

Response.Cookies ("isLoggedInAs")("username") =
userSet("username")
Response.cookies("isLoggedInAs") ("first_name") =
userSet("first_name")
Response.cookies("isLoggedInAs") ("last_name") =
userSet("last_name")

if p_save = "yes" then
Response.cookies("isLoggedInAs").expires = #December 31,
2003 00:00:00#
end if


spencerDB.Close
set spencerDB = Nothing

if Request.ServerVariables("HTTP_REFERER") =
"/homepage/chat.asp" then
Response.Redirect "/homepage/chat.asp"
end if

Response.Write "

Login Successfull!

"
Response.Write "

You are now successfully logged in, use the
menus at the top or bottom to navigate through this site."


else
'Username is not good, but password is wrong
Response.Redirect "/homepage/login.asp?retry=password"
end if
end if
%>




This baffles me as i have created the DSN in the advanced tools within
the control panel and selected an appropriate database. I am running
Windows 2003 server edition, using a Microsoft Access database. The same
error occurs with other pages trying to interact with the database.

Any help on this issue will be much appreciated.

Regards

Spencer

*** Sent via Developersdex http://www.developersdex.com ***

Re: SQL Error

am 19.09.2005 16:06:44 von McKirahan

"Spencer Hurst" wrote in message
news:OSlcHCSvFHA.2792@tk2msftngp13.phx.gbl...
>
>
> Hi, I have currently found an ASP based website that i developed about 3
> years ago and am very keen to get it up and running, it's quite a simple
> site, however when i try to do anything with the database i have a
> problem with the DSN (I Think).
>
> The error i get is something like the following:
> [Microsoft][ODBC Driver Manager]
> Drivers SQLSetConnectAttr failed.
> /homepage/takeregistration.asp line 10.
>
> The code from which this error is obtained is:
>
> <%@ LANGUAGE="VBSCRIPT" %>
> <% pageTitle = "Login - www.schurst.co.uk" %>
>
>
> <% p_userid = Request.form ("p_userid")
> p_pass = Request.form ("p_pass")
> p_save = Request.form ("p_save")
>
> set spencerDB = Server.CreateObject ("ADODB.Connection")
> spencerDB.Open "spencer" <<<<< LINE 10

[snip]

> This baffles me as i have created the DSN in the advanced tools within
> the control panel and selected an appropriate database. I am running
> Windows 2003 server edition, using a Microsoft Access database. The same
> error occurs with other pages trying to interact with the database.
>
> Any help on this issue will be much appreciated.
>
> Regards
>
> Spencer

Try using a DSN-less connection.

Change
spencerDB.Open "spencer" <<<<< LINE 10
to
Const cDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
spencerDB.Open cDSN & Server.MapPath(cMDB)

Re: SQL Error

am 19.09.2005 16:44:32 von McKirahan

I forgot to include this line:

Const cMDB = "spencer.mdb"

This should be the name of the file.

This presumes that it is in the same folder as your page.

Re: SQL Error

am 20.09.2005 12:49:22 von reb01501

Spencer Hurst wrote:
> Hi, I have currently found an ASP based website that i developed
> about 3 years ago and am very keen to get it up and running, it's
> quite a simple site, however when i try to do anything with the
> database i have a problem with the DSN (I Think).
>
The answer is simple: as McKirahan says: drop the DSN.

Instead of simply posting a new copy of your message to a different
newsgroup, you will find that you will get better help if you keep the
conversation in one place. For starters, you need to tell us why McKirahan's
answer did not solve your problem.

--
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"