Sql Compact 4.0 web config

Discussion in 'Databases' started by Swifter, Mar 1, 2012.

  1. I have a WCF web service running on top of Entity Framework with Sql Compact 4.0 and it runs fine on DiscountASP. I have added some web pages (.aspx) to the solution, running in a different application project. These web pages need access to the database for the web service, in its project.

    Now, the connection string for the Sql .sdf file in the web service uses the standard “Data Source = |DataDirectory|\Mydb.sdf” syntax. But, now I need the connection string for the web page project, and its |DataDirectory| in its web.config connection string will refer to its own project's App_Data folder.

    How can I point the web page project's connection string to the database in the web service project? On my local dev box, I would just use the absolute path, but I don't know how to do that on your hosting service.

    Thanks.
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

  3. Hello I new here anyway.......

    The problem is, that suddenly when browsing the website, that connects to the DATABASE through the providers I get this ERROR:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    My connection string looks like this below:

    <connectionStrings>
    <add name="TzSearchEntities"

    connectionString="metadata=.\Northwind.csdl|.\Northwind.ssdl|.\Northwind.msl;provider=System.Data.SqlClient;
    provider connection string=&quot;Data Source= esql2k802.discountasp.net;Initial Catalog=SQL2008_898285_me;User ID=SQL2008_898285_me_user;Password=luanda123;"

    providerName="System.Data.EntityClient" />
    </connectionStrings>


    I don't know if Imiss some thing could anyone help me please..
     
  4. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Make sure &quot; is an actual quote (").
     
  5. This give me this ERROR

    Error 1 An error occurred while parsing EntityName. Line 29, position 32.
     
  6. This is my code in the web.config


    <configuration>
    <connectionStrings>
    <add name="ApplicationServices"
    connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>



    <add name="TzSearchEntities"
    connectionString="metadata=res://*/Models.DataModel.csdl|res://*/Models.DataModel.ssdl|res://*/Models.DataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\TzSearch.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
    </connectionStrings>
     
  7. Problem with my connection string

    I don't if do I have to change anything.

    Thanks
     
  8. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    SQL Express is not supported. You need to change the connection string to point to your database here at DiscountASP.NET.
     

Share This Page