<div class="ForumPostContentText">got the following error in my site. am using visual studio 2005 vb.net sql server 2005. my webhost (philhost.net) said that they support mssql server 2005. please help
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces,
error: 26 - Error Locating Server/Instance Specified)
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not
allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source Error:
Line 16: Dim myConnection As New SqlConnection(strConnString) Line 17: Line 18: myConnection.Open() Line 19: Line 20: Dim myTrans=myConnection.BeginTransaction()
i can conect to the database in my local machine with no problem:
my connectionstring:
<connectionStrings> <add
name="ClientDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Client.MDF;Integrated Security=True;PWD=xxxxx;User
ID=me; User Instance=True"
providerName="System.Data.SqlClient"/>
</
connectionStrings>
my code:
Protected
Sub Button1_Click(ByVal sender
As
Object,
ByVal e
As System.EventArgs)
Handles Button1.Click
Dim strConnString
As String = ConfigurationManager.ConnectionStrings("ClientDBConnectionString").ConnectionString
Dim myConnection
As New SqlConnection(strConnString)
myConnection.Open()
Dim myTrans=myConnection.BeginTransaction()Dim myCommand
As New SqlCommand()
myCommand.Connection = myConnection
myCommand.Transaction = myTrans
Try
Dim iRegionID
As Integer
Dim sClientEmail
As String
sClientEmail =
""
sClientEmail = TextBox2.text
iRegionID = 0
iRegionID = TextBox1.Text
myCommand.CommandText =
"Insert into Region (RegionID, ClientEmail) VALUES (" & iRegionID &
", '" & sClientEmail &
"')"
myCommand.ExecuteNonQuery()
myTrans.Commit()
Response.Write("Both records are written to database.")Catch ep
As Exception
myTrans.Rollback()
Response.Write(ep.ToString())
Response.Write("Neither record was written to database.")
Finally
That's strange. I assume they must be having a clustered server. I do not see any specific security reasons.
They seem to be nervous about opening port 1433. Can you connect to the remote sql server using your Sql Server Management Studio? Just drop a mail to them to enquire about this.
how to connect using Sql Server Management Studio? what will i place in the server name? never tried connecting it to the internet before. I already emailed them about it and that's their response :(
However, i don't think it can solve you problem since if the server side doesn't allow remote connection, you will not be able to connect to the server using management studio neither.
Hope my suggestion helps
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Marked as answer by Bo Chen – MSFT on Sep 12, 2007 05:34 AM
i just phoned my webhost. they told me that their sql server 2005 is ok. it is not sql 2005 express but a licensed sql 2005. other client can connect to them with no problem. i asked them to provide me with sample connectionstring but they told me that
they cannot provide me with a sample and will give me links to tutorials instead.
could you help me on this guys?
could you give me a substitute connectionstring or a sample that will be able to connect to a licensed sql server? i could try every combination of connectionstring all day.
if i uploaded already my database to my website is it considered remote connection if somebody visit my website and connect(like order something and his orders will be save in my database) to my database using my site?
got this email from my webhost:
Hi,
We've already looked into your problem and it seems that the error occurs due to your connection string. This problem is on your side already and we can't provide you that string since we're just your host. Please consider searching sites that offers tutorial
or forums with regards to sql 2005 configuration.
Attachdbfilename can ONLY be used in sql express not sql 2005. So you cannot use attachdbfilename in your connection string in your case.
Try the connection string below
<add name="your connection string name" connectionString="Data Source=SERVER IP;Initial Catalog="Your CONNECT DB NAME";User ID=Your USER NAME;Password=YOUR PSW;"
providerName="System.Data.SqlClient" />
thanks
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Marked as answer by Bo Chen – MSFT on Sep 14, 2007 02:56 AM
WalangAlam
Member
10 Points
63 Posts
SQL Server 2005 does not allow remote connections
Sep 08, 2007 05:04 AM|LINK
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source Error:
Source File: E:\inetpub\vhosts\\httpdocs\Default.aspx.vb Line: 18
Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
</div>Suprotim Aga...
All-Star
15503 Points
1973 Posts
MVP
Re: SQL Server 2005 does not allow remote connections
Sep 08, 2007 07:23 AM|LINK
Hi,
Make sure your connection string is correct.
http://support.microsoft.com/default.aspx/kb/914277
HTH,
Suprotim Agarwal
-----
http://www.dotnetcurry.com
-----
Free Magazine for ASP.NET Developers
WalangAlam
Member
10 Points
63 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 10, 2007 12:07 AM|LINK
i can conect to the database in my local machine with no problem:
my connectionstring:
<connectionStrings> <add name="ClientDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Client.MDF;Integrated Security=True;PWD=xxxxx;User ID=me; User Instance=True" providerName="System.Data.SqlClient"/></
connectionStrings>my code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strConnString As String = ConfigurationManager.ConnectionStrings("ClientDBConnectionString").ConnectionString Dim myConnection As New SqlConnection(strConnString)myConnection.Open()
Dim myTrans=myConnection.BeginTransaction()Dim myCommand As New SqlCommand()myCommand.Connection = myConnection
myCommand.Transaction = myTrans
Try Dim iRegionID As Integer Dim sClientEmail As StringsClientEmail =
""sClientEmail = TextBox2.text
iRegionID = 0
iRegionID = TextBox1.Text
myCommand.CommandText =
"Insert into Region (RegionID, ClientEmail) VALUES (" & iRegionID & ", '" & sClientEmail & "')"myCommand.ExecuteNonQuery()
myTrans.Commit()
Response.Write("Both records are written to database.")Catch ep As ExceptionmyTrans.Rollback()
Response.Write(ep.ToString())
Response.Write("Neither record was written to database.") FinallymyConnection.Close()
End Try End SubWalangAlam
Member
10 Points
63 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 10, 2007 12:13 AM|LINK
from my webhost:
"For security purposes, we don't allow SQL server remote connection."
how will i be able to connect, edit and save to my database if this is the case?
Suprotim Aga...
All-Star
15503 Points
1973 Posts
MVP
Re: SQL Server 2005 does not allow remote connections
Sep 10, 2007 10:32 AM|LINK
That's strange. I assume they must be having a clustered server. I do not see any specific security reasons.
They seem to be nervous about opening port 1433. Can you connect to the remote sql server using your Sql Server Management Studio? Just drop a mail to them to enquire about this.
HTH,
Suprotim Agarwal
-----
http://www.dotnetcurry.com
-----
Free Magazine for ASP.NET Developers
WalangAlam
Member
10 Points
63 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 10, 2007 11:46 PM|LINK
how to connect using Sql Server Management Studio? what will i place in the server name? never tried connecting it to the internet before. I already emailed them about it and that's their response :(
Bo Chen – MS...
All-Star
17706 Points
1389 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 11, 2007 02:43 AM|LINK
Hi WalangAlam,
Connect to database engine using Management Studio is very easy. You can fill in the server IP in the sever name filed (if you don't have a managemnet studio installed, click here to download: https://www.microsoft.com/downloads/details.aspx?familyid=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en )
However, i don't think it can solve you problem since if the server side doesn't allow remote connection, you will not be able to connect to the server using management studio neither.
Hope my suggestion helps
Suprotim Aga...
All-Star
15503 Points
1973 Posts
MVP
Re: SQL Server 2005 does not allow remote connections
Sep 11, 2007 05:12 PM|LINK
Hi,
Remote connections need to be allowed. I wonder how would the others be connecting to the db hosted by your webhosting co.
HTH,
Suprotim Agarwal
-----
http://www.dotnetcurry.com
-----
Free Magazine for ASP.NET Developers
WalangAlam
Member
10 Points
63 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 13, 2007 12:25 AM|LINK
i just phoned my webhost. they told me that their sql server 2005 is ok. it is not sql 2005 express but a licensed sql 2005. other client can connect to them with no problem. i asked them to provide me with sample connectionstring but they told me that they cannot provide me with a sample and will give me links to tutorials instead.
could you help me on this guys?
could you give me a substitute connectionstring or a sample that will be able to connect to a licensed sql server? i could try every combination of connectionstring all day.
<add name="ClientDBConnectionString" connectionString="Data Source=.;AttachDbFilename=|DataDirectory|\Client.MDF;trusted_connection=yes" providerName="System.Data.SqlClient"/>
if i uploaded already my database to my website is it considered remote connection if somebody visit my website and connect(like order something and his orders will be save in my database) to my database using my site?
got this email from my webhost:
Hi,
</div>We've already looked into your problem and it seems that the error occurs due to your connection string. This problem is on your side already and we can't provide you that string since we're just your host. Please consider searching sites that offers tutorial or forums with regards to sql 2005 configuration.
Thank you!
Bo Chen – MS...
All-Star
17706 Points
1389 Posts
Re: SQL Server 2005 does not allow remote connections
Sep 13, 2007 02:16 AM|LINK
Hi walangalam,
Attachdbfilename can ONLY be used in sql express not sql 2005. So you cannot use attachdbfilename in your connection string in your case.
Try the connection string below
<add name="your connection string name" connectionString="Data Source=SERVER IP;Initial Catalog="Your CONNECT DB NAME";User ID=Your USER NAME;Password=YOUR PSW;"
providerName="System.Data.SqlClient" />
thanks