473,516 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connect to a database

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
|_____________________(_)

Jul 19 '05 #1
3 4464
"Peter Morris" wrote ...
Newbie question, I'm just learning ASP
Welcome aboard - tickets please :o)
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/le...id/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/de...dataadonet.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
Jul 19 '05 #2
"Peter Morris" wrote ...

[snip]

This might also be handy...

http://www.asp101.com/samples/viewas...database%2Easp

Do a search within that page for 'access connection code' - and it should
take you to the correct line in there example.

Robb
Jul 19 '05 #3

"Robb Meade" <ro********@NOSPAMkingswoodweb.net> wrote in message
news:P7**********************@news-text.cableinet.net...
"Peter Morris" wrote ...

[snip]

This might also be handy...

http://www.asp101.com/samples/viewas...database%2Easp

Do a search within that page for 'access connection code' - and it should
take you to the correct line in there example.

Robb


Thanks. one of the links you provided gave the correct connection string,
which is:
strConnection = "Driver={SQL Server}; Server=(local); Database=Northwind;
UID=sa; PWD=;"
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
4777
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " . mysql_error()); echo "Connected successfully"; mysql_close($link);
1
4759
by: DAVID | last post by:
Hello, With regards to the Connect dialog on Oracle forms 6i via which we can connect to Oracle database, should we use the same functionality on forms run time again? I mean, I want to make a window with three screen items for username, password and service name. And on run time after connecting to the database I use this window to...
3
6049
by: Lee | last post by:
Hi, I'm developing a socket program to connect to Informix database through the ODBC. In here i called my socket program as "tap" . My tap will listen for data from unix through port 1070. After checking of the data, tap will then insert the data to the informix database. I know we can point the tap to one specified port in Informix database...
4
5572
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or SQLNET in ORACLE that would allow me to connect to a database on a remote box (either AIX or AS/400)? I have read that DB2 Connect appears to be the...
4
6434
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to define the servername / hostname in my Perl Progrem.. Here is the code:
3
4555
by: Jassim Rahma | last post by:
I would like to know what is the best way to onnect to connect to a database in general which provides you with full functionality & fast access? Best Regards, Jassim Rahma *** Sent via Developersdex http://www.developersdex.com ***
1
2035
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on the same physical network, and it has an MSAccess database which is used on the external webfarm as well as on the internal intranet. I can connect...
21
2301
by: Steve | last post by:
I moved my database from one server to another SQL server. I did a backup and restore of the database. I can connect to the database on server A from my asp.net app but when I try to connect to my database server B, I'm gettting 'login failed for user 'username' I've added the username to the database on server B, I can open up SMS and connect...
2
9767
by: jeffhan | last post by:
we have os/400 db2 database at the backend. i installed db2 v9 connect server on one windows server which is locating the same network with database server. now how to i configure the connect server and client, so client could access the database through the connect server? like that: db2client <--db2 connect server <--db2 mainframe...
5
3116
by: danfan46 | last post by:
Hi! I have a previous post on the subject that connect takes a long time. I uninstalled db2 completely. Installed V9.5 Installed fixpack 1 created das created an instance installed database sample.
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.