locked
can not connect to database RRS feed

  • Question

  • User-511995934 posted

    i have set up a new hosting account with a provider (godaddy) and i opened the website in visual studio.

    i right clicked on the project and did an "add new item" and added a sql database (.mdf file) into the App_Data folder

    i created a table and added some data. all is well.

    i dragged and dropped a sqldatasource object onto a form and selected my database as the datasource

    i can step through and even test my sql and it returns the right data

    i can also see that VS automatically altered the web.config to now include my new connectionstring

    so why is it....when i access my site over the web.....as soon as the page tries to access the database, it spins and spins and i get:

    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)

    here's my web.config entry:

      <connectionStrings>
        <add name="Dental" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Company.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
      </connectionStrings>

    any ideas?


    Monday, January 23, 2012 12:49 PM

Answers

  • User311508580 posted

    Hi threeo,

    Please refer to our post. But, I would recommend you to contact your hosting provider to fix it. :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 23, 2012 10:27 PM
  • User3866881 posted

    Hello threeo:)

    This problem is too generic,and there are quite a lot of things that may cause this kind of problem……As far as I see,you should create a connection from Vs by "View"=>"Server Explorer" and make a connection there,and then copy the connection string from the right-down property panel and paste it into the web.config。

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 25, 2012 5:47 AM

All replies

  • User1958125286 posted

    Just Change the Permission for the App_Data from Read only to Read/Write and apply to all subfolders.

    This should fix the issue..

    Monday, January 23, 2012 2:44 PM
  • User-511995934 posted

    hmmm.....

    i guess....since this is a hosted account....i'll have to get the host to change the permissions on the app_data folder.

    i do see that it is read only (so why doesn't my initial page load which only reads data from the database?)

    seems like this would be a very common issue.

    also......i have another site that uses a sql2005 databased stored on another machine

    i copied the connectionstring over to this new site and received the same error - so that kinda rules out the "app_data" read/write thingy

    Monday, January 23, 2012 2:50 PM
  • User1958125286 posted

    Firstly, to change the permission you do not need to contact the hosting provider you can change the permission by yourself.If you have access to the control panel.

    The initial Page only reads data so thats why u can display the data but when you try to access the db i.e, for any CRUD then you cannot acess the DB.

    Why are you storing it in App_Data you can use SQL rite?

    Now, About your other website which uses SQL2005, Check the UserName and Password for the SQLServer The error which you are incurring is a common error as you might have noticed.

    This can be caused by any or all the above mentioned things..

    Monday, January 23, 2012 2:56 PM
  • User-511995934 posted

    now i'm really confused.....

    i went to my godaddy control panel and added a database and set it all up

    then back to visual studio and selected my sqldatasource control and configured it. in the drop-down list i saw the new database i had created

    so i know it recognizes it.

    but once again....over the net........it fails with the same error as above

    Monday, January 23, 2012 4:05 PM
  • User1958125286 posted

    This a VS Project rite and also did you delete all the old files on godaddy and published the new files on the hosting account rite?

    Sometimes as you might know the web.config might not have got overridden with the chnages specified so just try to publish the project after all previous files.

    Also check this post

    http://support.godaddy.com/groups/web-hosting/forum/topic/connecting-to-a-godaddy-sql-server-with-visual-studio-2008/

    Monday, January 23, 2012 4:13 PM
  • User311508580 posted

    Hi threeo,

    Please refer to our post. But, I would recommend you to contact your hosting provider to fix it. :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 23, 2012 10:27 PM
  • User3866881 posted

    Hello threeo:)

    This problem is too generic,and there are quite a lot of things that may cause this kind of problem……As far as I see,you should create a connection from Vs by "View"=>"Server Explorer" and make a connection there,and then copy the connection string from the right-down property panel and paste it into the web.config。

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 25, 2012 5:47 AM