I am setting up an ASP.Net site for the first time.
I have a remote SQL Server database which I can access OK on my default page.
Choosing an option on the default page starts another page which tries to reopen the connection to the database to use in a gridview.
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".
The connection string etc are identical to the default page.
Fair comment Nick but I've cut and pasted to remove chance of typos.
The following is simple code I'm using to check the connection.
It works on 1 page but not another.
Dim connection
AsNewSqlConnection("xxxxx") connection.Open() Dim
MyQueryCommand AsNewSqlCommand("xxxx",
connection) Dim
DtReader = MyQueryCommand.ExecuteReader() While
DtReader.Read() Response.Write(DtReader(0)) EndWhile DtReader.Close()
MyQueryCommand.ExecuteNonQuery()
connection.Close()
Please make usre your server name = yourcomputer_name/instance_name in your connect string and then connect your instance again. If the problem is still here, please post your connect string. Thanks a lot.
Thanks.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Thanks for the comment.
It's going to have to go down as unexplained.
I started from scratch and it now works but I can't find where the difference is.
I think this thread should now be closed
Marked as answer by Chen Yu - MSFT on Feb 18, 2013 01:25 AM
Alan Swift
0 Points
4 Posts
Connection Problem
Feb 04, 2013 10:59 AM|LINK
I am setting up an ASP.Net site for the first time.
I have a remote SQL Server database which I can access OK on my default page.
Choosing an option on the default page starts another page which tries to reopen the connection to the database to use in a gridview.
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".
The connection string etc are identical to the default page.
What am I doing wrong?
Nick Asiimwe
Participant
1459 Points
643 Posts
Re: Connection Problem
Feb 04, 2013 11:02 AM|LINK
I would re-check those connectionstrings once more just in case i missed or mistyped a some thing little.
Sincerely,
Nick
ASP.NET, SQL Server [Database Engine, SSIS & SSRS],Entity Framework, C# and VB.NET
Alan Swift
0 Points
4 Posts
Re: Connection Problem
Feb 04, 2013 12:29 PM|LINK
Fair comment Nick but I've cut and pasted to remove chance of typos.
The following is simple code I'm using to check the connection.
It works on 1 page but not another.
Dim connection As New SqlConnection("xxxxx")
connection.Open()
Dim MyQueryCommand As New SqlCommand("xxxx", connection)
Dim DtReader = MyQueryCommand.ExecuteReader()
While DtReader.Read()
Response.Write(DtReader(0))
End While
DtReader.Close()
MyQueryCommand.ExecuteNonQuery()
connection.Close()
Alan Swift
0 Points
4 Posts
Re: Connection Problem
Feb 04, 2013 12:45 PM|LINK
Sorry I should also have said that everything works fine using a local database on my PC.
The problem occurs when I connect to the database on my ISP
Chen Yu - MS...
All-Star
21584 Points
2493 Posts
Microsoft
Re: Connection Problem
Feb 12, 2013 02:44 AM|LINK
Hi,
Please make usre your server name = yourcomputer_name/instance_name in your connect string and then connect your instance again. If the problem is still here, please post your connect string. Thanks a lot.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store
Alan Swift
0 Points
4 Posts
Re: Connection Problem
Feb 13, 2013 08:20 PM|LINK
Hi
Thanks for the comment.
It's going to have to go down as unexplained.
I started from scratch and it now works but I can't find where the difference is.
I think this thread should now be closed