473,401 Members | 2,139 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,401 software developers and data experts.

error when connecting to sql server

Hi,

I get following error when trying to connect to a MDF file of sql server
express 2005 database:

"Microsoft OLE DB Service Components error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done"

The code in ASP file:
--------------------
<%
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open(application("newres"))
%>

global.asa:
----------
Sub Application_OnStart
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrated
Security=True;User Instance=True"
End Sub

Thanks for hrlp
Bart
Mar 22 '07 #1
10 3742
Bart wrote:
Hi,

I get following error when trying to connect to a MDF file of sql
server express 2005 database:

"Microsoft OLE DB Service Components error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done"

The code in ASP file:
--------------------
<%
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open(application("newres"))
%>

global.asa:
----------
Sub Application_OnStart
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
Security=True;User Instance=True"
End Sub
1. Why are you using the AttachDbFilename attribute? Do you have a
detached mdf file which you want to attach?
2. I assume you are substituting the real path to the data directory for
"|DataDirectory|"
(http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx)
3. You must specify the database name using the DATABASE attribute when
using the AttachDbFilename attribute
(http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx)


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 22 '07 #2
Hi Bob,

thanks for replying;
In fact, we have a webapplication written mainly in ASP.NET, but there are
still old ASP pages which must be converted later.
Meanwhile i have to work with them. The asp.net pages are not a problem
(provider sqlclient).

We use a mdf file which is located in the App_Data directory of the
application (sql server express 2005).
Sql server express 2005 is installed as "Servername\sqlexpress" with windows
authentification.

So i tried this with attribute Database but doesn't work:
"Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrated
Security=True;User Instance=True; Database=mewres.mdf"

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomschreef in bericht
news:uy**************@TK2MSFTNGP02.phx.gbl...
Bart wrote:
>Hi,

I get following error when trying to connect to a MDF file of sql
server express 2005 database:

"Microsoft OLE DB Service Components error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done"

The code in ASP file:
--------------------
<%
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open(application("newres"))
%>

global.asa:
----------
Sub Application_OnStart
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
>Security=True;User Instance=True"
End Sub
1. Why are you using the AttachDbFilename attribute? Do you have a
detached mdf file which you want to attach?
2. I assume you are substituting the real path to the data directory for
"|DataDirectory|"
(http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx)
3. You must specify the database name using the DATABASE attribute when
using the AttachDbFilename attribute
(http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx)


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Mar 22 '07 #3
Bart wrote:
Hi Bob,

thanks for replying;
In fact, we have a webapplication written mainly in ASP.NET, but
there are still old ASP pages which must be converted later.
Meanwhile i have to work with them. The asp.net pages are not a
problem (provider sqlclient).

We use a mdf file which is located in the App_Data directory of the
application (sql server express 2005).
Sql server express 2005 is installed as "Servername\sqlexpress" with
windows authentification.

So i tried this with attribute Database but doesn't work:
"Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
Security=True;User Instance=True; Database=mewres.mdf"
Again - are you substituting the true path to the file for
"|DataDirectory|"? If "|DataDirectory|" is a .Net keyword, classic ASP
has no concept of what it is.
I still don't understand why you are using AttachDbFilename. Why not
just use:

"Provider=SQLOLEDB; Data
Source=Servername\SQLEXPRESS;Integrated
Security=True;User Instance=True; Database=mewres"

Oh! I just noticed. The database name is probably not "mewres.mdf". It
would be very rare if the database had the same name as the file. More
likely, the name is as i showed in my example. Look at the result of
"select * from master..sysdatabases" to verify.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 22 '07 #4
Bob,

Sorry if i don't understand but I'm a little bit confused ...
I went to Sql server Management Studio express and did "select * from
master..sysdatabases".
I get a list of databases (master, model, tempdb, msdb) all located in
\program files\sql server .... Nothing else.

My MDF file is independant of sql server and located in App_Data of the
application.

To show you as example, for the aspx files, i use this string for the same
MDF file:
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient"

That's why i also use AttachDbFilename ...

I tried this now, but still same error:

Application("newres") = "Provider=SQLOLEDB; Data
Source=Servername\SQLEXPRESS;Integrated Security=True;User Instance=True;
Database=mewres.mdf"
....

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomschreef in bericht
news:OR**************@TK2MSFTNGP06.phx.gbl...
Bart wrote:
>Hi Bob,

thanks for replying;
In fact, we have a webapplication written mainly in ASP.NET, but
there are still old ASP pages which must be converted later.
Meanwhile i have to work with them. The asp.net pages are not a
problem (provider sqlclient).

We use a mdf file which is located in the App_Data directory of the
application (sql server express 2005).
Sql server express 2005 is installed as "Servername\sqlexpress" with
windows authentification.

So i tried this with attribute Database but doesn't work:
"Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
>Security=True;User Instance=True; Database=mewres.mdf"

Again - are you substituting the true path to the file for
"|DataDirectory|"? If "|DataDirectory|" is a .Net keyword, classic ASP
has no concept of what it is.
I still don't understand why you are using AttachDbFilename. Why not
just use:

"Provider=SQLOLEDB; Data
Source=Servername\SQLEXPRESS;Integrated
Security=True;User Instance=True; Database=mewres"

Oh! I just noticed. The database name is probably not "mewres.mdf". It
would be very rare if the database had the same name as the file. More
likely, the name is as i showed in my example. Look at the result of
"select * from master..sysdatabases" to verify.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Mar 22 '07 #5
Bart wrote:
Bob,

Sorry if i don't understand but I'm a little bit confused ...
I went to Sql server Management Studio express and did "select * from
master..sysdatabases".
I get a list of databases (master, model, tempdb, msdb) all located in
\program files\sql server .... Nothing else.
OK, that does explain the need to use AttachDbFilename.
>
My MDF file is independant of sql server and located in App_Data of
the application.

To show you as example, for the aspx files, i use this string for
the same MDF file:
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
Security=True;User Instance=True"
providerName="System.Data.SqlClient"
A classic ASP page will have absolutely NO concept of an App_Data
directory. It will have no idea of what to do with |DataDirectory|.
You MUST provide the actual physical path to the mdf file in the
AttachDbFilename attribute.
Again, the name of the database as seen by the server will never be
"mewres.mdf". What needs to be used is the logical name of the database,
not its physical name.

Create an aspx page which connects to the database and query that
sysdatabases table again to get the database's logical name.

Another approach you might want to consider is creating a .Net web
service to provide data, etc. for your classic asp pages ... nah, this
will require rewriting the asp pages and if you're going to do that, you
might as well convert them to .Net.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 22 '07 #6
Here are my next attempts:

First, i created an aspx to connect to the MDF file and did the select again
(select * from master..sysdatabases) to gain its logical name:
what i could see in a gridview was:
name
filename
----
------
master
c:\program files\sql server ...
model
.....
tempdb
.....
msdb
.....
c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf
c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf
So the logical name is: c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf
So i tried this connectionstring (in global.asa)
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and ... a new error: Provider error '80040e21'

i'm getting crazy.


"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomschreef in bericht
news:eG**************@TK2MSFTNGP03.phx.gbl...
Bart wrote:
>Bob,

Sorry if i don't understand but I'm a little bit confused ...
I went to Sql server Management Studio express and did "select * from
master..sysdatabases".
I get a list of databases (master, model, tempdb, msdb) all located in
\program files\sql server .... Nothing else.

OK, that does explain the need to use AttachDbFilename.
>>
My MDF file is independant of sql server and located in App_Data of
the application.

To show you as example, for the aspx files, i use this string for
the same MDF file:
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\newres.mdf;Integrat
ed
>Security=True;User Instance=True"
providerName="System.Data.SqlClient"

A classic ASP page will have absolutely NO concept of an App_Data
directory. It will have no idea of what to do with |DataDirectory|.
You MUST provide the actual physical path to the mdf file in the
AttachDbFilename attribute.
Again, the name of the database as seen by the server will never be
"mewres.mdf". What needs to be used is the logical name of the database,
not its physical name.

Create an aspx page which connects to the database and query that
sysdatabases table again to get the database's logical name.

Another approach you might want to consider is creating a .Net web
service to provide data, etc. for your classic asp pages ... nah, this
will require rewriting the asp pages and if you're going to do that, you
might as well convert them to .Net.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Mar 22 '07 #7
Bart wrote:
Here are my next attempts:

First, i created an aspx to connect to the MDF file and did the
select again (select * from master..sysdatabases) to gain its logical
name: what i could see in a gridview was:
name
filename
----
------
master
c:\program files\sql server ...
model
....
tempdb
....
msdb
....
c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf
c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf
So the logical name is:
c:\inetpub\wwwroot\reskrosql\App_Data\newres.mdf So i tried this
connectionstring (in global.asa)
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and ... a new error: Provider error '80040e21'
You left out the Database attribute. I would try both "DATABASE=newres" and
"DATABASE=c:\inetpub\wwwroot\reskrosql\App_Data\ne wres.mdf"

If those don't work, then it's time for me to admit defeat and send you to a
SQL Server group. Try m.p.sqlserver.programming.

--
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"
Mar 22 '07 #8
I tried this:

Application("newres") = "Provider=SQLOLEDB;DATABASE=newres;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and this:

Application("newres") =
"Provider=SQLOLEDB;DATABASE=c:\inetpub\wwwroot\res krosql\App_Data\newres.mdf;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

but unfortuantely, same error.
I can't imagine i'm the first who want to access an MDF file with an asp
page ...
Anyway, thanks for your help.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomschreef in bericht
news:ul**************@TK2MSFTNGP06.phx.gbl...

Bart wrote:
>Here are my next attempts:

First, i created an aspx to connect to the MDF file and did the
select again (select * from master..sysdatabases) to gain its logical
name: what i could see in a gridview was:
name
filename
----
------
master
c:\program files\sql server ...
model
....
tempdb
....
msdb
....
c:\inetpub\wwwroot\reskrosql\App_Data\newres.md f
c:\inetpub\wwwroot\reskrosql\App_Data\newres.md f
So the logical name is:
c:\inetpub\wwwroot\reskrosql\App_Data\newres.md f So i tried this
connectionstring (in global.asa)
Application("newres") = "Provider=SQLOLEDB; Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\w wwroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and ... a new error: Provider error '80040e21'
You left out the Database attribute. I would try both "DATABASE=newres"
and "DATABASE=c:\inetpub\wwwroot\reskrosql\App_Data\ne wres.mdf"

If those don't work, then it's time for me to admit defeat and send you to
a SQL Server group. Try m.p.sqlserver.programming.

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

Mar 23 '07 #9
Bart wrote:
I tried this:

Application("newres") = "Provider=SQLOLEDB;DATABASE=newres;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and this:

Application("newres") =
"Provider=SQLOLEDB;DATABASE=c:\inetpub\wwwroot\res krosql\App_Data\newres.mdf;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\ww wroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

but unfortuantely, same error.
I can't imagine i'm the first who want to access an MDF file with an
asp page ...
:-)
Let your imagination soar!

Sorry i could not help. If you get an answer form the sql server group, we
would really appreciate if you came back and posted the resolution here.

--
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"
Mar 23 '07 #10
.... if i find the solution ...

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomschreef in bericht
news:OF**************@TK2MSFTNGP06.phx.gbl...
Bart wrote:
>I tried this:

Application("newres") = "Provider=SQLOLEDB;DATABASE=newres;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\w wwroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

and this:

Application("newres") =
"Provider=SQLOLEDB;DATABASE=c:\inetpub\wwwroot\re skrosql\App_Data\newres.mdf;Data
Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\w wwroot\reskrosql\App_Data\newres.mdf;Integrated
Security=True;User Instance=True"

but unfortuantely, same error.
I can't imagine i'm the first who want to access an MDF file with an
asp page ...

:-)
Let your imagination soar!

Sorry i could not help. If you get an answer form the sql server group, we
would really appreciate if you came back and posted the resolution here.

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

Mar 23 '07 #11

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

Similar topics

14
by: David W. Fenton | last post by:
I'm no stranger to this error message, but I have a client who is experiencing it, but, fortunately, without any actual data corruption, and it's driving them made. Their inability to grasp that...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
6
by: Chris Love | last post by:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not...
7
by: deltalimagolf | last post by:
I now get the following error message after copying an asp.net application to the deployment web server. I don't have SQLExpress or any version of SQL 2005 installed. I found the "LocalSQLServer"...
1
by: John Shadel | last post by:
I have the following setup: 1. ASP.NET 2.0 web app hosted on a web server (inetpub directory hosting physical files of the web site on a different drive name, E: than the SQL Server Instance,...
5
by: James | last post by:
Hello, I have written a simple logon page that redirects to another page when successful. All works fine on my computer but when I upload it I get the error message below. I have written it...
1
by: NEWS | last post by:
My application is giving error .pls help . error : Server Error in '/webpdms' Application. -------------------------------------------------------------------------------- An error has...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
5
by: Cirene | last post by:
I just deployed my new ASP.NET (3.5 FW) site to the hosting company I'm using, webhost4life. NOTE: I HAVE deployed other SQL Server sites to the same account with no issues. Now I'm getting...
13
by: AAaron123 | last post by:
I downloaded the personal website starter kit and when I run it I get the error shown below. I found a way of using Launch Surface Area Configuration that is supposed to fix the remote setting...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.