Connection to a local database

Discussion in 'Databases' started by gnout, Jul 31, 2011.

  1. Hi,
    I'm trying to connect to a local database (A database file "Database.mdf" inside the App_Data directory) with an asp.net application (.net 4.0)
    First of all, is it possible?
    I'm using the following connection string

    <remove name="CurrConn"/>
    <add name="CurrConn" connectionString="Data Source=96.31.35.13;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Database.mdf;User Instance=true" providerName="System.Data.SqlClient" />

    I also added the following lines to my web config:

    <system.web>
    <trust level="Full" />
    </system.web>

    I'm getting the following error when I'm trying to run my application:

    Invalid value for key 'attachdbfilename'.

    I also tried the following "AttachDBFilename=|DataDirectory|/Database.mdf" but without any luck (I got the same error)

    How should I write the connectionstring in order to connect to local database file?

    Regards
    Dimitris
     
  2. Ray

    Ray

    You will not be able to do this. Trying to call and run a .mdf file which is a SQL database directly on the server will require that SQL Express be installed on the server. Unfortunately we do not support SQL Express on our shared hosting environment.
    Rather what you will need to do is use the SQL Tools in the control panel to upload your .mdf file to the SQL server. This of course will mean you have to update your connection string to look to the SQL server.
     

Share This Page