+1-888-365-2779
Try Now
More in this section

Forums / Deployment / Database Connection Problem

Database Connection Problem

7 posts, 1 answered
  1. gabs002
    gabs002 avatar
    64 posts
    Registered:
    17 Dec 2009
    12 Jan 2010
    Link to this post
    Hello sitefinity-Team,

    I got following issue:
    We got a webserver and we want to have our website (made with sitefinity) to run there. The problem is, that our SQL-Server is installed on a different server. Now I have problems, to get a connection to the sql-server.

    My connectionstring is looking like this:
    <add name="Sitefinity" connectionString="Data Source=SERVER\INSTANCE;Integrated Security=False;User ID=xxx;Password=xxx;AttachDBFilename=App_Data/Sitefinity.mdf" providerName="System.Data.SqlClient"/> 



    When I call the website I got a System.Data.SqlClient.SqlException. It says: Error when attaching Database for file App_Data/Sitefinity.mdf. A Database with this name does already exist, the file could not be opened or the file is on UNC share. (I transalted the german failure I got)
    btw: The whole directory of the website is shared in network. Maybe this is the problem?
    But I tried following:
    I copied all into a not-shared directory and I bind the page to this one and it does not work either.

    What else could it be?

    Hope you can help me with this problem!

    Thank You,
    Gabriele
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 Jan 2010
    Link to this post
    Hi Gabriele Muerth,

    Thank you for using our services.

    In your post you are saying this:
    The problem is, that our SQL-Server is installed on a different server.

    However in the connection string you are trying to connect the website to a physical .mdf file which the website is looking for in ~/App_Data/ folder of your website. Are you trying to connect the website to a .mdf file (SQLEXPRESS DB) or you want to connect to an SQL SERVER?

    If it is the first case and you want to connect to a SQLEXPRESS database .mdf file try something like this:
    <add name="Sitefinity" connectionString="Data Source=SERVER\INSTANCE;Integrated Security=False;User ID=xxx;Password=xxx;AttachDBFilename=FULLPATHTO/Sitefinity.mdf" providerName="System.Data.SqlClient"/>

    try to provide the full path to the db file.

     If it is the second case and you want to connect to another SQL Server where the DB is s hosted (not a .mdf file) can you try something like this:
    <add name="Sitefinity" connectionString="Data Source=SERVER\INSTANCE;Integrated Security=False;User ID=xxx;Password=xxx;initial catalog=DBNAME" providerName="System.Data.SqlClient"/>

    Where DBNAME is the name of the databases you have created for your website.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. gabs002
    gabs002 avatar
    64 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    Hi and thank you for your reply.

    In this case, I want to connect to a SQLEXPRESS database.
    If I provide the full path to the mdf-file it does not work either. I get the same error.

    Can it be, that I got wrong settings for my website/applicationpool in IIS? I'm using IIS7.

    Thank you,
    Gabriele
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Jan 2010
    Link to this post
    Hello Gabriele Muerth,

    Thank you for getting back to me.

    The only thing which matters from IIS configuration is the identity of the application pool in which your project is running. If it is ASPNET (default for classic application pool) you should give the ASP.NET worker process full access to your DB. If it is NETWORK SERVICE (default for integrated application pool) then the NETWORK SERVICE account should have full control over the DB. However I see that you are not using Integrated secutity for the connection string, this means that only the user you are authenticating on the SQL SERVER must have db_owner permissions for the attached DB.

    Since you are saying that you have SQL SERVER installed on a remote server can you try to create a regular DB in the SQL SERVER instead of attaching the mdf DB to the server, ant try to run the website with the just created DB (do not forget to add db_owner permissions to the user you are authenticating with).

    Looking forward to your response with the results.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  5. gabs002
    gabs002 avatar
    64 posts
    Registered:
    17 Dec 2009
    13 Jan 2010
    Link to this post
    Hello and thanks for your support!

    I've attached the database to the SQL-Server and modified the connectionstring. Now it works fine!

    Thank you,
    Gabriele
  6. jagadish kumar
    jagadish kumar avatar
    23 posts
    Registered:
    17 Mar 2010
    28 Jun 2010
    Link to this post
    Hello sir,

    Please guide me how to do the CRUD operation from the database in your sitefinity software

    It's very urgent

  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Jun 2010
    Link to this post
    Hello jagadish kumar,

    You can take a look at the following articles:
    Sitefinity Archivetcure
    Provider Model
    Working with Data in Sitefinity

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
7 posts, 1 answered