By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file

P: n/a
This is the exception that I get when i create a webserivce obj and
call. The error comes on the webmethod call, when it opens a
connection to the db.

How do I fix it? What is the solution to this?

System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file g:\inetpub\wwwroot
\BankingService\App_Data\BankingDb.mdf failed. A database with the
same name exists, or specified file cannot be opened, or it is located
on UNC share.

at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at
System.Data.SqlClient.SqlInternalConnectionTds.Com pleteLogin(Boolean
enlistOK)
at
System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String
newPassword, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo,
String newPassword, SqlConnection owningObject, Boolean
redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection
owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at
System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at BankingService.CheckPincode(String Pincode) in g:\Inetpub\wwwroot
\BankingService\App_Code\Service.cs:line 123

May 29 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The MDF file BankingDb, does a database with that name already exist on
the server you are trying to run this off of?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"weird0" <am********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
This is the exception that I get when i create a webserivce obj and
call. The error comes on the webmethod call, when it opens a
connection to the db.

How do I fix it? What is the solution to this?

System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file g:\inetpub\wwwroot
\BankingService\App_Data\BankingDb.mdf failed. A database with the
same name exists, or specified file cannot be opened, or it is located
on UNC share.

at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at
System.Data.SqlClient.SqlInternalConnectionTds.Com pleteLogin(Boolean
enlistOK)
at
System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String
newPassword, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo,
String newPassword, SqlConnection owningObject, Boolean
redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection
owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at
System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at BankingService.CheckPincode(String Pincode) in g:\Inetpub\wwwroot
\BankingService\App_Code\Service.cs:line 123

May 29 '07 #2

P: n/a
It looks like you are attempting to do an auto-attach of a SQLEXPRESS
database file. Normally this only works in development mode on the same
machine.
Instead, attach the database "the big boy way" to Sql Server on the remote
machine and use a "regular" connection string like:
server=machineName;database=yourdbname;uid=whateve r;pwd=pass;

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"weird0" wrote:
This is the exception that I get when i create a webserivce obj and
call. The error comes on the webmethod call, when it opens a
connection to the db.

How do I fix it? What is the solution to this?

System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file g:\inetpub\wwwroot
\BankingService\App_Data\BankingDb.mdf failed. A database with the
same name exists, or specified file cannot be opened, or it is located
on UNC share.

at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at
System.Data.SqlClient.SqlInternalConnectionTds.Com pleteLogin(Boolean
enlistOK)
at
System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String
newPassword, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo,
String newPassword, SqlConnection owningObject, Boolean
redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection
owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at
System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at BankingService.CheckPincode(String Pincode) in g:\Inetpub\wwwroot
\BankingService\App_Code\Service.cs:line 123

May 29 '07 #3

P: n/a
Hi! Like you pointed a different format for the connectionstring that
i am using to run the webservice locally...

server=machineName;database=yourdbname;uid=whateve r;pwd=pass;

Here is the connectionstring that i am using inside the code both for
client of webservice and website for asp.net location. And it does not
work for webserivce:

public static string connectionString = @"Data .
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Banki ngDb.mdf;Integrated
Security=True;User Instance=True";

What should be my connectionstring coz i dont think i have a username
and password for my db. Here is what i guess
it should be what you told? Is it correct? Can i just write
DataDirectory or do I have to specify the exact directory where the
database lies like on the desktop?

public static string connectionString = @"server=localhost;server=g:
\Documents and Setting\s2188\Desktop\App_Data
\BankingDb.mdf;User Instance=True";
May 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more C# / C Sharp Questions on Bytes