locked
Invalid value for key 'attachdbfilename' RRS feed

  • Question

  • User-1160646140 posted

    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'

     

    Wednesday, June 25, 2008 7:14 AM

All replies

  • User187056398 posted

    I think you are missing a backslash (Example from MSDN help:)

      AttachDbFilename=|DataDirectory|\Database1.mdf;

    Wednesday, June 25, 2008 7:22 AM
  • User-1160646140 posted

     i put space in AttachDbFilename=|DataDirectory|\Database1.mdf; then also give same error

     

    Wednesday, June 25, 2008 7:29 AM
  • User2011918074 posted

    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.  

    <add name="SqlServer" connectionString="Server=yoursqlservername_or_IP;
    userid=yourdbusername;password=yourdbuserpassword;database=databasename" 
    providerName="System.Data.SqlClient"/> 
     
     
    Hope this helps.
    Monday, June 30, 2008 4:31 AM
  • User-1160646140 posted
    this give error database stored procedure not found
    Monday, June 30, 2008 7:33 AM
  • User2011918074 posted

    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.

    Tuesday, July 1, 2008 1:59 AM
  • User-1160646140 posted
    i add full path of my of database then also not work
    Thursday, July 3, 2008 6:03 AM
  • User1912598878 posted

    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

    Saturday, October 22, 2011 10:43 PM
  • User1031964305 posted

    Thanks! This makes a lot of sense and saved me some time.

    Thursday, April 18, 2013 5:14 PM
  • User-1675407665 posted

    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\mydb.mdf;Integrated Security=True"
    providerName="System.Data.SqlClient" />

    I have a same problem. Here i am not missing back slash character, however i am facing this error

    Saturday, May 24, 2014 6:09 AM
  • User82333330 posted

    Hi,

    I have a same problem.

    Solution?

    Regards

    Monday, July 7, 2014 7:03 AM