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)
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..
Please remember to click “Mark as Answer” on the post that helps you.
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.
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。
threeo
Participant
1156 Points
539 Posts
can not connect to database
Jan 23, 2012 04:49 PM|LINK
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?
Sparkers
Contributor
2086 Points
470 Posts
Re: can not connect to database
Jan 23, 2012 06:44 PM|LINK
Just Change the Permission for the App_Data from Read only to Read/Write and apply to all subfolders.
This should fix the issue..
threeo
Participant
1156 Points
539 Posts
Re: can not connect to database
Jan 23, 2012 06:50 PM|LINK
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
Sparkers
Contributor
2086 Points
470 Posts
Re: can not connect to database
Jan 23, 2012 06:56 PM|LINK
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..
threeo
Participant
1156 Points
539 Posts
Re: can not connect to database
Jan 23, 2012 08:05 PM|LINK
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
Sparkers
Contributor
2086 Points
470 Posts
Re: can not connect to database
Jan 23, 2012 08:13 PM|LINK
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/
dotnetnerd
Contributor
2434 Points
551 Posts
Re: can not connect to database
Jan 24, 2012 02:27 AM|LINK
Hi threeo,
Please refer to our post. But, I would recommend you to contact your hosting provider to fix it. :)
Windows ASP.NET Hosting | Reseller Hosting | Cloud Hosting
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: can not connect to database
Jan 25, 2012 09:47 AM|LINK
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。