473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error 80004005 when creating recordset object in ASP file, but works fine in Global.ASA

For some reason I am getting an error when trying to open a recordset on an
Access database on my Win2K3 machine from my INDEX.ASP page, but the same
code accesses the database fine when coming from the GLOBAL.ASA page. I'm
using a DSN to connect to the database.

The error I'm getting is:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/index.asp, line 14

My code looks like:
dim objConn
set objConn= server.CreateObject("ADODB.Connection")
objConn.Open "DNS=SparesDB.dsn"
dim objRS
set objRS = server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT * FROM tblUsers WHERE UserName='" &
request.form("txtuser") & "' AND Password='" & request.form("txtPass") &
"';", objConn, ,3
if objRS.recordcount=1 then
...some code

The error occurs in 'set objRS = server.CreateObject("ADODB.Recordset")'

The DSN has no username/password. I have both disabling and enabling
anonymous access to the web site. Disabling access forces me to enter a
valid domain username/password combination when GLOBAL.ASA is executed, but
I still get the same error in my INDEX.ASP page.

My files are located as follows:
- D:\Internet\mypage.com\web holds my web pages (ASP, HTML, CSS, images,
etc.)
- D:\Internet\mypage.com\db holds my MS Access database (I will eventually
migrate the database to a proper MS SQL server)
- My DSN is named "SparesDB.dsn", has no password and points to my Access
file.

Since my DB folder is at the same level as my WEB folder, I shouldn't need
to specify a username or password... At least this is what I found online:
"With DSN and User ID/Password (NOTE: a user/pass is NOT needed if you place
your database in the /database directory on the same level as the public
/html directory so this is rarely used)" Is it necessary to actually name
the folders "html" and "database" ???

Any assistance is appreciated!!!
Jul 19 '05 #1
12 5914
The problem is this line:

objConn.Open "DNS=SparesDB.dsn"

Instead, use:

objConn.Open "DSN=SparesDB"

(note DSN is misspelt, and you don't need the extension if you have a system
DSN, since the information is stored in the registry).

That said you should probably use the Jet OLEDB Provider instead.

Cheers
Ken
"Grahammer" <po********@127.0.0.1> wrote in message
news:ef**************@TK2MSFTNGP12.phx.gbl...
: For some reason I am getting an error when trying to open a recordset on
an
: Access database on my Win2K3 machine from my INDEX.ASP page, but the same
: code accesses the database fine when coming from the GLOBAL.ASA page. I'm
: using a DSN to connect to the database.
:
: The error I'm getting is:
: Microsoft OLE DB Provider for ODBC Drivers error '80004005'
: [Microsoft][ODBC Driver Manager] Data source name not found and no
: default driver specified
: /index.asp, line 14
:
: My code looks like:
: dim objConn
: set objConn= server.CreateObject("ADODB.Connection")
: objConn.Open "DNS=SparesDB.dsn"
: dim objRS
: set objRS = server.CreateObject("ADODB.Recordset")
: objRS.Open "SELECT * FROM tblUsers WHERE UserName='" &
: request.form("txtuser") & "' AND Password='" & request.form("txtPass") &
: "';", objConn, ,3
: if objRS.recordcount=1 then
: ...some code
:
: The error occurs in 'set objRS = server.CreateObject("ADODB.Recordset")'
:
: The DSN has no username/password. I have both disabling and enabling
: anonymous access to the web site. Disabling access forces me to enter a
: valid domain username/password combination when GLOBAL.ASA is executed,
but
: I still get the same error in my INDEX.ASP page.
:
: My files are located as follows:
: - D:\Internet\mypage.com\web holds my web pages (ASP, HTML, CSS, images,
: etc.)
: - D:\Internet\mypage.com\db holds my MS Access database (I will
eventually
: migrate the database to a proper MS SQL server)
: - My DSN is named "SparesDB.dsn", has no password and points to my Access
: file.
:
: Since my DB folder is at the same level as my WEB folder, I shouldn't need
: to specify a username or password... At least this is what I found online:
: "With DSN and User ID/Password (NOTE: a user/pass is NOT needed if you
place
: your database in the /database directory on the same level as the public
: /html directory so this is rarely used)" Is it necessary to actually name
: the folders "html" and "database" ???
:
: Any assistance is appreciated!!!
:
:
Jul 19 '05 #2
Do I feel like an idiot!

I stared at that thing for an HOUR!

I appreciate it muchly!

BTW... I'm quite new to this. What is involved in using the Jet OLEDB
provider?

Thanks!
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
The problem is this line:

objConn.Open "DNS=SparesDB.dsn"

Instead, use:

objConn.Open "DSN=SparesDB"

(note DSN is misspelt, and you don't need the extension if you have a system DSN, since the information is stored in the registry).

That said you should probably use the Jet OLEDB Provider instead. "Grahammer" <po********@127.0.0.1> wrote in message
news:ef**************@TK2MSFTNGP12.phx.gbl...
: For some reason I am getting an error when trying to open a recordset on an
: Access database on my Win2K3 machine from my INDEX.ASP page, but the same : code accesses the database fine when coming from the GLOBAL.ASA page. I'm : using a DSN to connect to the database.
:
: The error I'm getting is:
: Microsoft OLE DB Provider for ODBC Drivers error '80004005'
: [Microsoft][ODBC Driver Manager] Data source name not found and no : default driver specified
: /index.asp, line 14

Jul 19 '05 #3
strConnect = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\database\myDatabase.mdb;"

If you don't know the physical path to your database, you can use the
Server.Mappath() function to return the physical path.

The latest Jet Provider is available here:
http://support.microsoft.com/default...;en-us;282010&

Cheers
Ken

"Grahammer" <we*******@127.0.0.1> wrote in message
news:e%****************@TK2MSFTNGP12.phx.gbl...
: Do I feel like an idiot!
:
: I stared at that thing for an HOUR!
:
: I appreciate it muchly!
:
: BTW... I'm quite new to this. What is involved in using the Jet OLEDB
: provider?
:
: Thanks!
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:uG**************@TK2MSFTNGP10.phx.gbl...
: > The problem is this line:
: >
: > objConn.Open "DNS=SparesDB.dsn"
: >
: > Instead, use:
: >
: > objConn.Open "DSN=SparesDB"
: >
: > (note DSN is misspelt, and you don't need the extension if you have
: a system
: > DSN, since the information is stored in the registry).
: >
: > That said you should probably use the Jet OLEDB Provider instead.
:
: > "Grahammer" <po********@127.0.0.1> wrote in message
: > news:ef**************@TK2MSFTNGP12.phx.gbl...
: > : For some reason I am getting an error when trying to open a
: recordset on
: > an
: > : Access database on my Win2K3 machine from my INDEX.ASP page, but
: the same
: > : code accesses the database fine when coming from the GLOBAL.ASA
: page. I'm
: > : using a DSN to connect to the database.
: > :
: > : The error I'm getting is:
: > : Microsoft OLE DB Provider for ODBC Drivers error '80004005'
: > : [Microsoft][ODBC Driver Manager] Data source name not found and
: no
: > : default driver specified
: > : /index.asp, line 14
:
:
Jul 19 '05 #4
Thanks Ken!

I'll look into it.

At the moment, portability is more important that performance.

This system MAY move to a MSSQL server, MySQL or possibly Oracle. If I
read correctly the ODBC connection provided by the DSN provides a
common interface to these databases.

I will do some more digging though.

Thanks!
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
strConnect = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\database\myDatabase.mdb;"

If you don't know the physical path to your database, you can use the Server.Mappath() function to return the physical path.

The latest Jet Provider is available here:
http://support.microsoft.com/default...;en-us;282010&

Cheers
Ken

"Grahammer" <we*******@127.0.0.1> wrote in message
news:e%****************@TK2MSFTNGP12.phx.gbl...
: Do I feel like an idiot!
:
: I stared at that thing for an HOUR!
:
: I appreciate it muchly!
:
: BTW... I'm quite new to this. What is involved in using the Jet OLEDB : provider?
:
: Thanks!
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:uG**************@TK2MSFTNGP10.phx.gbl...
: > The problem is this line:
: >
: > objConn.Open "DNS=SparesDB.dsn"
: >
: > Instead, use:
: >
: > objConn.Open "DSN=SparesDB"
: >
: > (note DSN is misspelt, and you don't need the extension if you have : a system
: > DSN, since the information is stored in the registry).
: >
: > That said you should probably use the Jet OLEDB Provider instead. :
: > "Grahammer" <po********@127.0.0.1> wrote in message
: > news:ef**************@TK2MSFTNGP12.phx.gbl...
: > : For some reason I am getting an error when trying to open a
: recordset on
: > an
: > : Access database on my Win2K3 machine from my INDEX.ASP page, but : the same
: > : code accesses the database fine when coming from the GLOBAL.ASA : page. I'm
: > : using a DSN to connect to the database.
: > :
: > : The error I'm getting is:
: > : Microsoft OLE DB Provider for ODBC Drivers error '80004005'
: > : [Microsoft][ODBC Driver Manager] Data source name not found and : no
: > : default driver specified
: > : /index.asp, line 14
:
:

Jul 19 '05 #5
Grahammer wrote:
Thanks Ken!

I'll look into it.

At the moment, portability is more important that performance.

This system MAY move to a MSSQL server, MySQL or possibly Oracle. If I
read correctly the ODBC connection provided by the DSN provides a
common interface to these databases.

I will do some more digging though.

Thanks!

That reasoning makes no sense.

If the database server name does not change when the app is ported, the
connection string does not have to change. If the database server name can
be different, the DSN would have to change as well when the app is ported..
There really is no advantage to using a DSN. In fact, MS recommends against
it:
http://msdn.microsoft.com/library/en...deprecated.asp
(see the section that talks about MSDASQL )

ADO communicates with ODBC (DSN) via the MSDASQL provider.

Bob Barrows

Jul 19 '05 #6

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Grahammer wrote:
Thanks Ken!

I'll look into it.

At the moment, portability is more important that performance.

This system MAY move to a MSSQL server, MySQL or possibly Oracle. If I read correctly the ODBC connection provided by the DSN provides a
common interface to these databases.

I will do some more digging though.

Thanks!

That reasoning makes no sense.


It does to me... I don't know what I'm doing, yet!
If the database server name does not change when the app is ported, the connection string does not have to change. If the database server name can be different, the DSN would have to change as well when the app is ported..

I was just looking at "www.connectionstrings.com and see that when
using OLEDB:

For a MSSQL server - "Provider=sqloledb;Data Source=Aron1;Initial
Catalog=pubs;User Id=sa;Password=asdasd;"

For an Access database - "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\somepath\mydb.mdb;User Id=admin;Password=;"

but when using a DSN I can use the following for either kind of
database: "DSN=myDsn;Uid=username;Pwd=;"

So what this means is I just have to alter the DSN to point to a new
kind of database once I move my tables from Access to MSSQL. Seems
simpler to me. (Also, doesn't the DSN connection do some SQL
conversion when there are differences in how a specific database type
works?)
There really is no advantage to using a DSN. In fact, MS recommends against it:
http://msdn.microsoft.com/library/en...deprecated.asp (see the section that talks about MSDASQL )

ADO communicates with ODBC (DSN) via the MSDASQL provider.


This is a good reason to switch though. I want to use the current
technology. I'll be looking at it!
Jul 19 '05 #7
> http://msdn.microsoft.com/library/en...deprecated.asp
(see the section that talks about MSDASQL )


Thanks, added this link to www.aspfaq.com/2126
Jul 19 '05 #8
> So what this means is I just have to alter the DSN to point to a new
kind of database once I move my tables from Access to MSSQL.


Big deal.

How often are you planning to migrate? Once?

By using a DSN, you ease administrative hassles when you move to a new
machine (never mind migrating database platforms) -- someone with admin
privileges on the web server will have to add the DSN if you switch servers,
and many hosts charge a fee for that.

By using the native OLE-DB provider, you ensure slightly better performance
through the life of the app, and are not using deprecated,
soon-to-be-unsupported technology.

And if you think changing the DSN is going to be the biggest hassle when you
move from Access to SQL Server, you might want to go over this article:
http://www.aspfaq.com/2214
Jul 19 '05 #9
> By using a DSN, you ease administrative hassles

Sorry, this should say add, not ease.

Also, a recommendation: store your connection string in an #include file
that gets referenced in all data access pages, or in an application variable
from global.asa. This way, when you migrate to a real database, "all that
hard work" of changing the connection string is only done once, instead of
multiple times (or with a search and replace tool, if all the files have an
identical connection string).

Or, maybe, you could just use MSDE now, instead of mucking with Crap-cess at
all. The transition from MSDE to SQL Server will be essentially seamless.
Jul 19 '05 #10

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
By using a DSN, you ease administrative hassles
Sorry, this should say add, not ease.

Also, a recommendation: store your connection string in an #include

file that gets referenced in all data access pages, or in an application variable from global.asa.
Definately will be doing this.
This way, when you migrate to a real database, "all that
hard work" of changing the connection string is only done once, instead of multiple times (or with a search and replace tool, if all the files have an identical connection string).

Or, maybe, you could just use MSDE now, instead of mucking with Crap-cess at all. The transition from MSDE to SQL Server will be essentially

seamless.

I'd love to, but I keep getting told, "That's good... Can you do this
as well?" At that point I have to start altering the tables and such
and find Access is much easier to manage at that point. I'm probably
overlooking some MSSQL tool that lets me work with tables just as
easily, but I haven't found it.

At this point I'm more interested in getting some kind of system
running to present.

I appreciate all the help!
Jul 19 '05 #11
> I'd love to, but I keep getting told, "That's good... Can you do this
as well?" At that point I have to start altering the tables and such
and find Access is much easier to manage at that point. I'm probably
overlooking some MSSQL tool that lets me work with tables just as
easily, but I haven't found it.


No offence, but that seems like a pretty lame excuse for deciding on a
database platform, IMHO.

I can't see that Enterprise Manager is any more difficult than the Access
GUI (except there are way more options). However, I typically recommend
against using EM in most cases, opting for Query Analyzer (see
http://www.aspfaq.com/2455). However, this requires some knowledge of
constructing both DML and DDL statements. Also, there are many tools out
there you can use to manage MSDE / SQL Server, and many are "dumbed down" to
a simple point and click interface, several web-based... see
http://www.aspfaq.com/2442 for a partial list. Some of these tools might
even be usable with Access.
Jul 19 '05 #12
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:Op****************@TK2MSFTNGP12.phx.gbl...
So what this means is I just have to alter the DSN to point to a new
kind of database once I move my tables from Access to MSSQL.
Big deal.

How often are you planning to migrate? Once?

By using a DSN, you ease administrative hassles when you move to a new
machine (never mind migrating database platforms) -- someone with

admin privileges on the web server will have to add the DSN if you switch servers, and many hosts charge a fee for that.

By using the native OLE-DB provider, you ensure slightly better performance through the life of the app, and are not using deprecated,
soon-to-be-unsupported technology.

And if you think changing the DSN is going to be the biggest hassle when you move from Access to SQL Server, you might want to go over this article: http://www.aspfaq.com/2214


I wanted to make a few clarifications:
1. DSN-Less connections are supported for ODBC as well as OLEDB. So I
think we can all agree that from an administrative standpoint, DSN-Less
connections are the way to go.
2. The original poster (OP) does make a valid point about the
portability benefits of ODBC over using the native OLEDB provider for
SQL-Server. ODBC should (theoretically) blackbox all the implementation
differences among the underlying databases, such as those described in
the aforementioned aspfaq article, at the expense of performance and
stability. That being said, I would like to propose that instead of
relying on ODBC as a universal translator that you uses parameterized
queries/stored procedures to create a interface layer between your
database and your external apps. This way you can reap the benefits of
using OLEDB while retaining a measure of the portability offered by
ODBC. To my mind, a nicely implemented stored procedure interface layer
is what distinguishes a database application from just another bunch of
tables.

I've been seeing recurring examples of this "happy median" or "sweet
spot" principle. I get the feeling that there's some sort of homeostasis
thing going on. Anyway, that's my $0.02.

HTH
-Chris
Jul 19 '05 #13

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

Similar topics

2
by: Robert May | last post by:
Using SaFileUp to upload a file through HTTPS. The same installation of FileUp only errors in this application. The file is then parsed in real time in a VB6 dll. The Response Object is obtained...
8
by: middletree | last post by:
I had some text links at the top of all my pages (in one include file), which worked just fine. But I was asked to make it so that people in a certain department, (this is an Intranet app) would...
2
by: sunj | last post by:
My database completely works in Dreamweaver MX at a local testing level, but as soon as I upload and access my web pages remotely I get this error on the browser. Can anyone help?...
4
by: Bryan Tang | last post by:
I built an ASP to search the content in index server. It is ok if search in English. Whenever I search in Chinese, I will got the following error message, CreateRecordset ?u?~ '80004005' ...
1
by: MyndPhlyp | last post by:
I am about to completely lose what is left of my poor mynd! The historical dissertation gets rather verbose, so I hope you can wade through it all. I really need some help on this one or I'm...
8
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As...
5
by: Bronislav | last post by:
I have an error when I try to delete last record in the record set. The code I'm using is: lcurrow = Me.BindingContext(DsTextProdMain, "TextProductsMain").Current lcurrow.Delete() This code...
2
by: ago | last post by:
I am trying to make the win32com HelloWorld server work with a VBA client but I get: Run-time error '-2147467259(80004005)': Automation error Unspecified error I googled for the error but...
1
by: ziottt | last post by:
Hi everybody My problem with sql server is the following one: I've got my backoffice manager application done with asp technology that works on sql server installed on Win2000 and running on IIS5....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.