connect to a database

P

Peter Morris

Newbie question, I'm just learning ASP

I am having trouble connecting to a database. I have set up the
ODBC data source Northwind to link to the Northwind database.

Now, I'm running the following script:

<% @language = vbscript %>
<%
Option explicit
Response.expires = 0
dim objConn, objRS, strQuery
dim strConnection
Set ObjConn = server.createObject("ADODB.connection")
strConnection = "DSN=Northwind;database=northwind;"
strConnection = strConnection & "UID=sa;PWD=;"
objConn.open strConnection
....
%>

This produces the following error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user
'YOUR-D10B605044\IUSR_YOUR-D10B605044'.
/asp24/hour13/readdata.asp, line 10


Why is this happening? Why can't I connect?

Note - there doesn't seem to be anything wrong with the database or the
DSN. I have created a visual basic program which successfully opens
and reads the same database and DSN. This connects like so:

Dim cnn1 As ADODB.Connection
Dim rstRec As ADODB.Recordset
Dim strCnn As String

Sub main()
Set cnn1 = New ADODB.Connection
strCnn = "DSN=Northwind;Database=Northwind;UID=sa;PWD=;"
cnn1.Open strCnn
End Sub

Why does it work in visual basic, but not in VBScript? Is there
perhaps something I must configure in IIS for it to work, or something
like that?

--
_______________________
/_____________________(_)
| ______________________ email to
| | |__________________(_) Peter_Morris_1 at
| |/____________________ btinternet dot com
|_____________________(_)
 
R

Robb Meade

...
Newbie question, I'm just learning ASP

Welcome aboard - tickets please :eek:)
I am having trouble connecting to a database. I have set up the
ODBC data source Northwind to link to the Northwind database.

hmm...I've not used ASP and Access databases together, usually SQL, so I'm
not sure if I can be much help...

Couple of things to check,

I took this :

Access connection string looks like this;
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp\Northwind.mdb"

from

http://www.tek-tips.com/gfaqs.cfm/lev2/4/lev3/31/pid/333/fid/178

and also this:

A typical connection string for the Access Northwind database is:
"provider=Microsoft.Jet.OLEDB.4.0; data source=YourPath\Northwind.MDB"

from

http://msdn.microsoft.com/library/d...y/en-us/dv_vstechart/html/jstchdataadonet.asp


again, I've not connected into an Access database from ASP before, but the
connection string would be the first thing I'd look at.

Followed by double checking the username/password - as the error message
does suggest a login problem.

And also the permissions on the directory that the access database is stored
in, if you plan to write to the database I think you'll need to enable the
'write' permission from the ISM within IIS (I might be wrong).

Good luck!

Robb
 

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

Members online

Forum statistics

Threads
474,261
Messages
2,571,041
Members
48,769
Latest member
Clifft

Latest Threads

Top