Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #1035 > unrolled thread
| Started by | "Tony" <johansson.andersson@telia.com> |
|---|---|
| First post | 2012-05-10 19:33 +0200 |
| Last post | 2012-05-10 22:44 -0700 |
| Articles | 8 — 3 participants |
Back to article view | Back to comp.databases.ms-sqlserver
How do I fix this error "Tony" <johansson.andersson@telia.com> - 2012-05-10 19:33 +0200
Re: How do I fix this error Erland Sommarskog <esquel@sommarskog.se> - 2012-05-10 23:53 +0200
Re: How do I fix this error "Tony" <johansson.andersson@telia.com> - 2012-05-11 00:27 +0200
Re: How do I fix this error Erland Sommarskog <esquel@sommarskog.se> - 2012-05-11 09:02 +0200
Re: How do I fix this error "Tony" <johansson.andersson@telia.com> - 2012-05-11 10:34 +0200
Re: How do I fix this error "Tony" <johansson.andersson@telia.com> - 2012-05-11 11:14 +0200
Re: How do I fix this error Erland Sommarskog <esquel@sommarskog.se> - 2012-05-11 12:54 +0200
Re: How do I fix this error bradbury9 <ray.bradbury9@gmail.com> - 2012-05-10 22:44 -0700
| From | "Tony" <johansson.andersson@telia.com> |
|---|---|
| Date | 2012-05-10 19:33 +0200 |
| Subject | How do I fix this error |
| Message-ID | <4fabfbd0$0$290$14726298@news.sunsite.dk> |
I have tried with Visual Studio 2010 Proffessional and Visual Web developer express 2010 but I get the following error when I try to run the web site. I have also sql server 2008 installed. I addending a cource and when I try to run the web site that we have got as examples I get this error. Does anyone know how to correct so I can run the examples ? Here is the error that I get ******************* An attempt to attach an auto-named database for file G:\ASP Module 3\CarsDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file G:\ASP Module 3\CarsDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SqlException (0x80131904): An attempt to attach an auto-named database for file G:\ASP Module 3\CarsDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064458 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +183 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126 System.Data.SqlClient.SqlConnection.Open() +125 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +3409 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +96 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +225 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +127 System.Web.UI.WebControls.GridView.DataBind() +29 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +107 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +131 System.Web.UI.Control.EnsureChildControls() +162 System.Web.UI.Control.PreRenderRecursiveInternal() +120 System.Web.UI.Control.PreRenderRecursiveInternal() +307 System.Web.UI.Control.PreRenderRecursiveInternal() +307 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4834 //Tony -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
[toc] | [next] | [standalone]
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Date | 2012-05-10 23:53 +0200 |
| Message-ID | <XnsA04FF3151DD17Yazorman@127.0.0.1> |
| In reply to | #1035 |
Tony (johansson.andersson@telia.com) writes: > I have tried with Visual Studio 2010 Proffessional and Visual Web > developer express 2010 but I get the following error when I try to run > the web site. I have also sql server 2008 installed. I addending a > cource and when I try to run the web site that we have got as examples I > get this error. > Does anyone know how to correct so I can run the examples ? > > > Here is the error that I get > ******************* > An attempt to attach an auto-named database for file G:\ASP Module > 3\CarsDB.mdf failed. A database with the same name exists, or specified > file cannot be opened, or it is located on UNC share. Reading the error message, there appears to be three possibilities: 1) You already have a database CarsDB. 2) There is no file G:\ASP Module 3\CarsDB.mdf 3) G is a mapped network drive. The AttachDBFilename is a connection-string option that I've never understood the point with. Why not just attach the database once and for all? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
[toc] | [prev] | [next] | [standalone]
| From | "Tony" <johansson.andersson@telia.com> |
|---|---|
| Date | 2012-05-11 00:27 +0200 |
| Message-ID | <4fac40d5$0$293$14726298@news.sunsite.dk> |
| In reply to | #1039 |
It was path problem that I had now it works.
But I wonder you mentioned that using the AttachDBFilename was not so good
according to you
If I have a database called CarsDB.mdf with these setting in web.config how
would I write to skip this
AttachDBFilename ?
The CarsDB.mdf is located in the App_data folder which the DataDirectory is
refering to.
<connectionStrings>
<add name="CarsDBConnectionString2" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CarsDB.mdf;
Integrated Security=True;User Instance=True" />
</connectionStrings>
//Tony
"Erland Sommarskog" <esquel@sommarskog.se> skrev i meddelandet
news:XnsA04FF3151DD17Yazorman@127.0.0.1...
> Tony (johansson.andersson@telia.com) writes:
>> I have tried with Visual Studio 2010 Proffessional and Visual Web
>> developer express 2010 but I get the following error when I try to run
>> the web site. I have also sql server 2008 installed. I addending a
>> cource and when I try to run the web site that we have got as examples I
>> get this error.
>> Does anyone know how to correct so I can run the examples ?
>>
>>
>> Here is the error that I get
>> *******************
>> An attempt to attach an auto-named database for file G:\ASP Module
>> 3\CarsDB.mdf failed. A database with the same name exists, or specified
>> file cannot be opened, or it is located on UNC share.
>
> Reading the error message, there appears to be three possibilities:
>
> 1) You already have a database CarsDB.
> 2) There is no file G:\ASP Module 3\CarsDB.mdf
> 3) G is a mapped network drive.
>
> The AttachDBFilename is a connection-string option that I've never
> understood the point with. Why not just attach the database once and
> for all?
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
>
[toc] | [prev] | [next] | [standalone]
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Date | 2012-05-11 09:02 +0200 |
| Message-ID | <XnsA0505C0EC2366Yazorman@127.0.0.1> |
| In reply to | #1041 |
Tony (johansson.andersson@telia.com) writes: > It was path problem that I had now it works. But I wonder you mentioned > that using the AttachDBFilename was not so good according to you If I > have a database called CarsDB.mdf with these setting in web.config how > would I write to skip this AttachDBFilename ? > > The CarsDB.mdf is located in the App_data folder which the DataDirectory > is refering to. > ><connectionStrings> > <add name="CarsDBConnectionString2" connectionString="Data > Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CarsDB.mdf; > Integrated Security=True;User Instance=True" /> > </connectionStrings> Attach the database to the servce once for all and change AttachDbFilename to Database, strip ".mdf" and take out "User Instance=True". -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
[toc] | [prev] | [next] | [standalone]
| From | "Tony" <johansson.andersson@telia.com> |
|---|---|
| Date | 2012-05-11 10:34 +0200 |
| Message-ID | <4faccf1e$0$287$14726298@news.sunsite.dk> |
| In reply to | #1043 |
I can't find the mdf file when I try to attach the database in Attach Database dialog. I have SQL Server 2008. Here is what I do. 1. I start Sql Server management studio and use server name: Alexandra-dator\SQLEXPRESS and Window authentication 2.I right click on the Database and select attach 3. I click on Add and try to find my database file that is called CarsDB.mdf and this file is located at C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data\CarsDB.mdf but I can't find this file This is the way that is described in the documentation how it should be done. So I wonder what is it that I doing wrong when I can't find the mdf file ? //Tony "Erland Sommarskog" <esquel@sommarskog.se> skrev i meddelandet news:XnsA0505C0EC2366Yazorman@127.0.0.1... > Tony (johansson.andersson@telia.com) writes: >> It was path problem that I had now it works. But I wonder you mentioned >> that using the AttachDBFilename was not so good according to you If I >> have a database called CarsDB.mdf with these setting in web.config how >> would I write to skip this AttachDBFilename ? >> >> The CarsDB.mdf is located in the App_data folder which the DataDirectory >> is refering to. >> >><connectionStrings> >> <add name="CarsDBConnectionString2" connectionString="Data >> Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CarsDB.mdf; >> Integrated Security=True;User Instance=True" /> >> </connectionStrings> > > Attach the database to the servce once for all and change AttachDbFilename > to Database, strip ".mdf" and take out "User Instance=True". > > -- > Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se > > Links for SQL Server Books Online: > SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx > SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx >
[toc] | [prev] | [next] | [standalone]
| From | "Tony" <johansson.andersson@telia.com> |
|---|---|
| Date | 2012-05-11 11:14 +0200 |
| Message-ID | <4facd958$0$287$14726298@news.sunsite.dk> |
| In reply to | #1044 |
In addition to not finding the mdf file I tried another thing. I just copied the mdf and ldf file to C:\tmp. Now I can attach to the mdf file but when I do so another strange thing accur the database that is listed Under Databases in the SQL Server management Studio now show C:\USERS\TONY\PROGRAMMERING\EXEMPEL\ASPCH09_3_1\APP_DATA\CARSDB.MDF I have thought that it should show C:\TMP\CARSDB.MDF. I don't understand this can anybody explain why the item under Database show this C:\USERS\TONY\PROGRAMMERING\EXEMPEL\ASPCH09_3_1\APP_DATA\CARSDB.MDF instead of this C:\TMP\CARSDB.MDF As a summary I have two question My first question why does not the mdf file exist in C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data ? My second question when I copied the mdf and ldf file to C:\tmp from C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data how could the attached mdf file show this C:\USERS\TONY\PROGRAMMERING\EXEMPEL\ASPCH09_3_1\APP_DATA\CARSDB.MDF in the Databases in sql Server Management Studio insted of C:\tmp ? //Tony >I can't find the mdf file when I try to attach the database in Attach >Database dialog. > I have SQL Server 2008. Here is what I do. > 1. I start Sql Server management studio and use server name: > Alexandra-dator\SQLEXPRESS and Window authentication > 2.I right click on the Database and select attach > 3. I click on Add and try to find my database file that is called > CarsDB.mdf and this file is located at > C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data\CarsDB.mdf > but I can't find this file > > This is the way that is described in the documentation how it should be > done. > So I wonder what is it that I doing wrong when I can't find the mdf file ? > > //Tony > > > > > "Erland Sommarskog" <esquel@sommarskog.se> skrev i meddelandet > news:XnsA0505C0EC2366Yazorman@127.0.0.1... >> Tony (johansson.andersson@telia.com) writes: >>> It was path problem that I had now it works. But I wonder you mentioned >>> that using the AttachDBFilename was not so good according to you If I >>> have a database called CarsDB.mdf with these setting in web.config how >>> would I write to skip this AttachDBFilename ? >>> >>> The CarsDB.mdf is located in the App_data folder which the DataDirectory >>> is refering to. >>> >>><connectionStrings> >>> <add name="CarsDBConnectionString2" connectionString="Data >>> Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CarsDB.mdf; >>> Integrated Security=True;User Instance=True" /> >>> </connectionStrings> >> >> Attach the database to the servce once for all and change >> AttachDbFilename >> to Database, strip ".mdf" and take out "User Instance=True". >> >> -- >> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se >> >> Links for SQL Server Books Online: >> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx >> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx >> >
[toc] | [prev] | [next] | [standalone]
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Date | 2012-05-11 12:54 +0200 |
| Message-ID | <XnsA05083400C804Yazorman@127.0.0.1> |
| In reply to | #1044 |
Tony (johansson.andersson@telia.com) writes: > I can't find the mdf file when I try to attach the database in Attach > Database dialog. > I have SQL Server 2008. Here is what I do. > 1. I start Sql Server management studio and use server name: > Alexandra-dator\SQLEXPRESS and Window authentication > 2.I right click on the Database and select attach > 3. I click on Add and try to find my database file that is called > CarsDB.mdf and this file is located at > C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data\CarsDB.mdf > but I can't find this file CREATE DATABASE CarsDB ON (FILENAME = 'C:\Users\Tony\programmering\Exempel\ASPCh09_3_1\App_Data\CarsDB.mdf') FOR ATTACH Although normally, you would have the database in the DATA directory of the SQL Server installation. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
[toc] | [prev] | [next] | [standalone]
| From | bradbury9 <ray.bradbury9@gmail.com> |
|---|---|
| Date | 2012-05-10 22:44 -0700 |
| Message-ID | <7659906.610.1336715079870.JavaMail.geo-discussion-forums@vbq19> |
| In reply to | #1041 |
El viernes, 11 de mayo de 2012 00:27:28 UTC+2, Tony escribió: > It was path problem that I had now it works. > But I wonder you mentioned that using the AttachDBFilename was not so good > according to you > If I have a database called CarsDB.mdf with these setting in web.config how > would I write to skip this > AttachDBFilename ? > The CarsDB.mdf is located in the App_data folder which the DataDirectory is > refering to. > > <connectionStrings> > <add name="CarsDBConnectionString2" connectionString="Data > Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CarsDB.mdf; > Integrated Security=True;User Instance=True" /> > </connectionStrings> > > //Tony > > > "Erland Sommarskog" skrev i meddelandet > news:XnsA04FF3151DD17Yazorman@127.0.0.1... > > Tony writes: > >> I have tried with Visual Studio 2010 Proffessional and Visual Web > >> developer express 2010 but I get the following error when I try to run > >> the web site. I have also sql server 2008 installed. I addending a > >> cource and when I try to run the web site that we have got as examples I > >> get this error. > >> Does anyone know how to correct so I can run the examples ? > >> > >> > >> Here is the error that I get > >> ******************* > >> An attempt to attach an auto-named database for file G:\ASP Module > >> 3\CarsDB.mdf failed. A database with the same name exists, or specified > >> file cannot be opened, or it is located on UNC share. > > > > Reading the error message, there appears to be three possibilities: > > > > 1) You already have a database CarsDB. > > 2) There is no file G:\ASP Module 3\CarsDB.mdf > > 3) G is a mapped network drive. > > > > The AttachDBFilename is a connection-string option that I've never > > understood the point with. Why not just attach the database once and > > for all? > > > > -- > > Erland Sommarskog, SQL Server MVP > > > > Links for SQL Server Books Online: > > SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx > > SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx > > Try not to double post
[toc] | [prev] | [standalone]
Back to top | Article view | comp.databases.ms-sqlserver
csiph-web