how to setup a dsn-less connection

M

Matthew

Hello, I know I may be asking a lot but I am not very good at script in fact I know nothing. I have a page with the following code and I would like to make the connection DSN-less. - - 'Check the database to see if user exsits and read in there password
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "users"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath(strAccessDB)

'Set an active connection to the Connection object
adoCon.Open strCon

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

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Password FROM tblUsers WHERE tblUsers.UserID ='" & strUserName & "'"

'Query the database
rsCheckUser.Open strSQL, strCon
 
K

Ken Ford - PVII Support

This is a DSN-less connection:

strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath(strAccessDB)

--
Ken Ford
Certified Dreamweaver MX 2004 Developer
PVII Support Team
http://www.projectseven.com


(e-mail address removed)...
Hello, I know I may be asking a lot but I am not very good at script in fact I know nothing. I have a page with the following code
and I would like to make the connection
- 'Check the database to see if user
exsits and read in there password
 
M

Matthew

then what type of connection is this I was told this was dsn-less - oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\somepath\mydb.mdb;" &
"Uid=admin;" &
"Pwd=
 
K

Ken Ford - PVII Support

That one is a DSN-less connection as well, it is using the physical path to the database file.

The other one you posted is using Server.MapPath to the database file.

I'm assuming that you are trying to use the other one to connect to your database.

Do you know the physical location of the database file on your server?

--
Ken Ford
PVII Support Team
http://www.projectseven.com


Matthew said:
then what type of connection is this I was told this was dsn-less -
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
 
M

Matthew

Yes my database is located in the root web in the folder database the name of the database is users. I started this to begin with because I have a login asp script that calls the usernames from the database. and I couldnt get it to retrieve from database so my host told me to create a DSN but they were not going very quick and i was told dsnless connections were better. regardless I would like to have as much control as possible without host interference. Thanks for your quick responses.
 
K

Ken Ford - PVII Support

Before you try anything else, try changing this:

strAccessDB = "users"

To this:

strAccessDB = "users.mdb"

If that does not work try this:

Create a .asp page with the following in the <body> of the page:

<%=Server.MapPath("/")%>

Save the page in the same folder that your database is in.

Then browse to the page in IE and you should see something like this:

c:\inetpub\wwwroot\database

One of the following should work. Keep these on one line:

strCon = "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\inetpub\wwwroot\database\users.mdb;Uid=;Pwd=;"

or this one:

strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\database\users.mdb;User Id=;Password=;"

If your database has a username and password be sure to add them

--
Ken Ford
PVII Support Team
http://www.projectseven.com


Matthew said:
Yes my database is located in the root web in the folder database the name of the database is users. I started this to begin with
because I have a login asp script that calls the usernames from the database. and I couldnt get it to retrieve from database so my
host told me to create a DSN but they were not going very quick and i was told dsnless connections were better. regardless I would
like to have as much control as possible without host interference. Thanks for your quick responses.
 
M

Matthew

Sorry I am using so much of your time but I really appreciate it. I did what you said with the body page and recieved this line of code instead - E:\Accounts\roadhous - I tried to modify the two lines you sent me but the first one gave same error i always got and second one gave this error- Microsoft JET Database Engine error '80040e4d'

Cannot start your application. The workgroup information file is missing or opened exclusively by another user.

/check_user.asp, line 26
the code on line 26 reads like this - 'Set an active connection to the Connection objec
adoCon.Open strCon
the code I am using is the exact code on http://www.webwizguide.info/asp/sample_scripts/database_login_script.asp I have the same username and password still in effect I am just trying to get it to work. THanks for your help. Matt
 
M

Matthew

Congratulations Ford- you did it. really thanks a lot it is working now. So I guess it looks like the problem was having the database password protected. Why wouldnt I be able to password protect them? You dont even have to answer I think youve done enough. THanks Matt
 
K

Ken Ford - PVII Support

Glad it is working and I don't know the answer to your question :)

--
Ken Ford
Certified Dreamweaver MX 2004 Developer
PVII Support Team
http://www.projectseven.com


Matthew said:
Congratulations Ford- you did it. really thanks a lot it is working now. So I guess it looks like the problem was having the
database password protected. Why wouldnt I be able to password protect them? You dont even have to answer I think youve done enough.
THanks Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Forgotten Password script 1
dsn-less question! 1
DSN Less Connection 2
DSN-Less Connection Help 10
Timestamp in Webforms & Access 2
Add field to password logon. 3
Capture User Names in Web Forms? 1
ADODB Connection 3

Top