PC Review


Reply
Thread Tools Rate Thread

connection string with AttachDBFileName=... doesn't work

 
 
R.A.M.
Guest
Posts: n/a
 
      8th Oct 2007
Hello,
I am writing ASP.NET application using SQL Server 2005 Express Edition.
In web.config I have:

<connectionStrings>
<add name="MIM-Magazyn_Demo"
connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\MIM-Magazyn_Demo.mdf;Database=MIM-Magazyn_Demo;Trusted_Connection=Yes"
providerName="System.Data.SqlClient"/>

<add name="SqlServices"
connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\aspnetdb.mdf;Database=aspnetdb;Trusted_Connection=Yes"/>

</connectionStrings>

I used connection strings syntax from www.connectionstrings.com. I decided
to use AttachDBFileName because I don't expect that application user will
have both databases attached in SQL Server Management Studio.

The problem is that during execution, in a line:

Membership mu = Membership.GetUser();

I receive System.Data.SqlClient.SqlException
{"Cannot create file
'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb_log.LDF' because it
already exists. Change the file path or the file name, and retry the
operation.\r\nCould not open new database 'aspnetdb'. CREATE DATABASE is
aborted.\r\nCould not attach file
'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb.mdf' as database
'aspnetdb'.\r\nFile activation failure. The physical file name
\"F:\\inetpub\\wwwroot\\MIMMagazyn\\App_Data\\aspnetdb_log.LDF\" may be
incorrect."}

Could you help me please to solve the problem?
Thank you!!!
/RAM/


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SklHTkVTSA==?=
Guest
Posts: n/a
 
      8th Oct 2007
Membership data is stored in this database 'aspnetdb'. if this db does not
exists
it automatically creates one, so it you don;t have it , it will create one 4
you.

also lets rule out permissions issue, check if folder has R/W permission.

Regards
JIGNESH

"R.A.M." wrote:

> Hello,
> I am writing ASP.NET application using SQL Server 2005 Express Edition.
> In web.config I have:
>
> <connectionStrings>
> <add name="MIM-Magazyn_Demo"
> connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\MIM-Magazyn_Demo.mdf;Database=MIM-Magazyn_Demo;Trusted_Connection=Yes"
> providerName="System.Data.SqlClient"/>
>
> <add name="SqlServices"
> connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\aspnetdb.mdf;Database=aspnetdb;Trusted_Connection=Yes"/>
>
> </connectionStrings>
>
> I used connection strings syntax from www.connectionstrings.com. I decided
> to use AttachDBFileName because I don't expect that application user will
> have both databases attached in SQL Server Management Studio.
>
> The problem is that during execution, in a line:
>
> Membership mu = Membership.GetUser();
>
> I receive System.Data.SqlClient.SqlException
> {"Cannot create file
> 'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb_log.LDF' because it
> already exists. Change the file path or the file name, and retry the
> operation.\r\nCould not open new database 'aspnetdb'. CREATE DATABASE is
> aborted.\r\nCould not attach file
> 'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb.mdf' as database
> 'aspnetdb'.\r\nFile activation failure. The physical file name
> \"F:\\inetpub\\wwwroot\\MIMMagazyn\\App_Data\\aspnetdb_log.LDF\" may be
> incorrect."}
>
> Could you help me please to solve the problem?
> Thank you!!!
> /RAM/
>
>
>

 
Reply With Quote
 
R.A.M.
Guest
Posts: n/a
 
      8th Oct 2007
Użytkownik "JIGNESH" <(E-Mail Removed)> napisał w
wiadomości news:F497B1E3-E0BC-4CFA-B10D-(E-Mail Removed)...
> Membership data is stored in this database 'aspnetdb'. if this db does not
> exists
> it automatically creates one, so it you don;t have it , it will create one
> 4
> you.

I have it created.

> also lets rule out permissions issue, check if folder has R/W permission.

I have R/W permission.


 
Reply With Quote
 
Norman Yuan
Guest
Posts: n/a
 
      11th Oct 2007
Please study a bit more on SQL Server Express "User Instance" and
"AttachDBFileName". If you have created the database for your ASP.NET 2.0
website, there is not need to use "User Instance" and attaching DB file each
time a request is sent to the website.

I am sick of all entry level .NET books showing code examples using SQL
Server Express user instance/AttachDBFile to newbies without whole chapter
to explain the special User Instance clearly.This has confused so many
newbies. Just see how many questions are related to this in various NGs.


"R.A.M." <(E-Mail Removed)> wrote in message
news:fecep2$au4$(E-Mail Removed)...
> Hello,
> I am writing ASP.NET application using SQL Server 2005 Express Edition.
> In web.config I have:
>
> <connectionStrings>
> <add name="MIM-Magazyn_Demo"
> connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\MIM-Magazyn_Demo.mdf;Database=MIM-Magazyn_Demo;Trusted_Connection=Yes"
> providerName="System.Data.SqlClient"/>
>
> <add name="SqlServices"
> connectionString="Server=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\aspnetdb.mdf;Database=aspnetdb;Trusted_Connection=Yes"/>
>
> </connectionStrings>
>
> I used connection strings syntax from www.connectionstrings.com. I decided
> to use AttachDBFileName because I don't expect that application user will
> have both databases attached in SQL Server Management Studio.
>
> The problem is that during execution, in a line:
>
> Membership mu = Membership.GetUser();
>
> I receive System.Data.SqlClient.SqlException
> {"Cannot create file
> 'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb_log.LDF' because it
> already exists. Change the file path or the file name, and retry the
> operation.\r\nCould not open new database 'aspnetdb'. CREATE DATABASE is
> aborted.\r\nCould not attach file
> 'F:\\Inetpub\\wwwroot\\MIM-Magazyn\\App_Data\\aspnetdb.mdf' as database
> 'aspnetdb'.\r\nFile activation failure. The physical file name
> \"F:\\inetpub\\wwwroot\\MIMMagazyn\\App_Data\\aspnetdb_log.LDF\" may be
> incorrect."}
>
> Could you help me please to solve the problem?
> Thank you!!!
> /RAM/
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dim String doesn't work Plateriot Microsoft ASP .NET 0 4th Dec 2008 06:41 AM
SQL string with date doesn't work Andreas Microsoft Access Form Coding 2 9th May 2008 03:04 PM
Why doesn't this string reverse work with the space for this particular string? sherifffruitfly Microsoft C# .NET 5 15th Aug 2007 11:22 PM
ODBC connection works, but connection string doesn't =?Utf-8?B?am9uZWZlcg==?= Microsoft ADO .NET 8 23rd Jan 2006 11:02 PM
if (string[i]=="f") doesn'work -string, char type mismatch beginner Microsoft C# .NET 4 22nd Oct 2003 02:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 AM.