What is the SQL server 2005 edition in your connection string? Is it a SQL server 2005 Express edition?
We can attach or visit the database file in “App_Data” folder with “AttachDbFilename=|DataDirectory|\Test.mdf;” in SQL Server 2000 Express edition, so if it’s other editions of SQL Server, you may attach the database file in the “SQL Server Management Studio”
, then remove the “AttachDbFilename=|DataDirectory|\Test.mdf;” from the connection string and modify it as usual.
Please replace the "|DataDirectory|" with the full physical path of the database file in your original connection string, and try to check whether it works.
Hope this helps.
Jian Kang
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
prajapatiami...
Member
548 Points
395 Posts
Invalid value for key 'attachdbfilename'
Jun 25, 2008 11:14 AM|LINK
My project my db in app_data folder db name is test.mdf
and my connection string is
<add name="realestate" connectionString="Data Source= ftpIP;Network Library=DBMSSOCN;user id=ftpuser;password=ftppassword; AttachDbFilename= |DataDirectory|Test.mdf; Integrated Security = false;" />
<add name="ConnectionString" connectionString="Data Source=ftpIP;Network Library=DBMSSOCN;user id=ftpuser;password=ftppassword;AttachDbFilename=|DataDirectory|Test.mdf;Integrated Security=False;"
providerName="System.Data.SqlClient" />
when i run my application that give me error
Invalid value for key 'attachdbfilename'
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
SGWellens
All-Star
126031 Points
10310 Posts
Moderator
Re: Invalid value for key 'attachdbfilename'
Jun 25, 2008 11:22 AM|LINK
I think you are missing a backslash (Example from MSDN help:)
AttachDbFilename=|DataDirectory|\Database1.mdf;
My blog
prajapatiami...
Member
548 Points
395 Posts
Re: Invalid value for key 'attachdbfilename'
Jun 25, 2008 11:29 AM|LINK
i put space in AttachDbFilename=|DataDirectory|\Database1.mdf; then also give same error
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
Jian Kang - ...
All-Star
33132 Points
2465 Posts
Re: Invalid value for key 'attachdbfilename'
Jun 30, 2008 08:31 AM|LINK
Hi prajapatiamit2003,
What is the SQL server 2005 edition in your connection string? Is it a SQL server 2005 Express edition?
We can attach or visit the database file in “App_Data” folder with “AttachDbFilename=|DataDirectory|\Test.mdf;” in SQL Server 2000 Express edition, so if it’s other editions of SQL Server, you may attach the database file in the “SQL Server Management Studio” , then remove the “AttachDbFilename=|DataDirectory|\Test.mdf;” from the connection string and modify it as usual.
Hope this helps.
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
prajapatiami...
Member
548 Points
395 Posts
Re: Invalid value for key 'attachdbfilename'
Jun 30, 2008 11:33 AM|LINK
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
Jian Kang - ...
All-Star
33132 Points
2465 Posts
Re: Invalid value for key 'attachdbfilename'
Jul 01, 2008 05:59 AM|LINK
Hi prajapatiamit2003,
Please replace the "|DataDirectory|" with the full physical path of the database file in your original connection string, and try to check whether it works.
Hope this helps.
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
prajapatiami...
Member
548 Points
395 Posts
Re: Invalid value for key 'attachdbfilename'
Jul 03, 2008 10:03 AM|LINK
Amitsp(MCTS,MCP)
sqlreporting.blogspot.com
vnisman
Member
10 Points
5 Posts
Re: Invalid value for key 'attachdbfilename'
Oct 23, 2011 02:43 AM|LINK
I had this problem with Invalid 'AttachDbFileName' parameter
Spent couple hours trying to find any good documentation but eventually here is what seems to be going on:
I was using Data Source=localhost;AttachDbFileName=|DataDirectory|Movies.mdf;....
When I changed to Data Source=(local); or alternatively: Data Source=.; the connection worked just fine.
My conclusion is that AttachDbFileName is not supported over TCP connection used when localhost/IP is specified.
On another hand, the AttachDbFileName works fine over Named Pipes (local) or '.' (Must be on the same machine!)
http://weblogs.asp.net/jgalloway/archive/2005/12/02/432062.aspx
ultrafastnea...
Member
16 Points
5 Posts
Re: Invalid value for key 'attachdbfilename'
Apr 18, 2013 09:14 PM|LINK
Thanks! This makes a lot of sense and saved me some time.
Neal Ganslaw
MCAD, MCDBA