PC Review


Reply
Thread Tools Rating: Thread Rating: 3 votes, 2.33 average.

Connecting to Sql Server using an IP address

 
 
David Thielen
Guest
Posts: n/a
 
      16th Mar 2009
Hi;

We can connect fine using ADO.NET when we connect to a server by name.
But when we try to connect by IP address, it works for systems on our
subnet, but not for machines further away - including ones that we can
connect to by name.

We pass the IP address as the name of the server. Do we need to use
something other than Data Source=1.2.3.4 and/or put something else in
the connection string?

thanks - dave


david@at-at-(E-Mail Removed)
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Reply With Quote
 
 
 
 
David Thielen
Guest
Posts: n/a
 
      16th Mar 2009
PS - I forgot, if there is a different syntax:

1) How is this used for the native Sql Server ADO.NET connection, ODBC
ADO.NET connection, and OleDb ADO.NET connection?

2) Does this difference hold for other vendors? And if so, the same
syntax change?

thanks - dave


On Mon, 16 Mar 2009 16:44:14 -0600, David Thielen
<(E-Mail Removed)> wrote:

>Hi;
>
>We can connect fine using ADO.NET when we connect to a server by name.
>But when we try to connect by IP address, it works for systems on our
>subnet, but not for machines further away - including ones that we can
>connect to by name.
>
>We pass the IP address as the name of the server. Do we need to use
>something other than Data Source=1.2.3.4 and/or put something else in
>the connection string?
>
>thanks - dave
>
>
>david@at-at-(E-Mail Removed)
>Windward Reports -- http://www.WindwardReports.com
>me -- http://dave.thielen.com
>
>Cubicle Wars - http://www.windwardreports.com/film.htm



david@at-at-(E-Mail Removed)
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Reply With Quote
 
David Thielen
Guest
Posts: n/a
 
      17th Mar 2009
>> Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

Is this all versions of Sql Server or just 2008?

thanks - dave


On Tue, 17 Mar 2009 02:26:55 -0000, "Mark Rae [MVP]"
<(E-Mail Removed)> wrote:

>"David Thielen" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>
>> We pass the IP address as the name of the server. Do we need to use
>> something other than Data Source=1.2.3.4 and/or put something else in
>> the connection string?

>
>http://www.connectionstrings.com/sql-server-2008



david@at-at-(E-Mail Removed)
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Reply With Quote
 
David Thielen
Guest
Posts: n/a
 
      17th Mar 2009
On the Network Library= vs Network= - which is it for the
SqlConnection, OdbcConnection, & OleDbConnection?

Also if the user types in the server and we have to determine if it's
an IP address vs a name, any suggestions on the best way? Because a
server name can start with a number. Can server names have a . in
them?

thanks - dave


On Tue, 17 Mar 2009 02:26:55 -0000, "Mark Rae [MVP]"
<(E-Mail Removed)> wrote:

>"David Thielen" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>
>> We pass the IP address as the name of the server. Do we need to use
>> something other than Data Source=1.2.3.4 and/or put something else in
>> the connection string?

>
>http://www.connectionstrings.com/sql-server-2008



david@at-at-(E-Mail Removed)
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Reply With Quote
 
Lingzhi Sun [MSFT]
Guest
Posts: n/a
 
      17th Mar 2009
Hello David,

Your situation reminded me about another similar case: Under network
protocol TCP/IP, using IP address without port number (default port number
of SQL Server is 1433) cannot connect to the SQL Server on a remote
machine, using server name does not work either; under network protocol
named pipes, both using IP address without port number and using server
name in the connection string can connect the remote machine successfully.


The root cause of that case is the port number of SQL Server when
connecting under the network protocol TCP/IP. If the port has been
changed to other port numbers, we need to modify the connection string when
using IP address to connect to the SQL Server and add set the network
protocol as TCP/IP. The connection string can be "Data
Source=*.*.*.*,1500(the new port number);Network
Library=DBMSSOCN(TCP/IP)…". For detail, please see
http://www.connectionstrings.com/sql-server-2005 and
http://www.connectionstrings.com/Art...er-network-pro
tocol.

Therefore, I recommend you start from checking the TCP/IP port setting to
troubleshoot this issue. Please refer to this article to check the port
setting in the SQL Server:
http://msdn.microsoft.com/en-us/library/ms177440(SQL.90).aspx.

If the problem is not caused by TCP/IP port settings, you can also follow
this KB article to check whether the remote SQL Server has been set
correctly to accept remote connections,
http://support.microsoft.com/kb/914277.

For your second question on how the native SQL Server ADO.NET connection,
ODBC ADO.NET connection and OLEDB ADO.NET connection accept the IP address,
please see the following analysis:
//////////////////////////////////////////////////////////////

Native SQL Server ADO.NET Connection:
Could you please clarify what do you mean by native SQL Server ADO.NET
conection?

//////////////////////////////////////////////////////////////

ODBC ADO.NET Connection:
For SQL Server:
You can use such an ODBC connection string to connect the database:
"Driver={SQL Server}; Server=***.***.***.***(IP address),****(port number);
Database=DatabaseName; Uid=***; Pwd=***".

For IBM DB2:
Here are the keywords in the connection string:
Keyword "NTL=TCPIP" for TCP/IP connection
Keyword "NA" for IP address and "NP" for network port
For detail, please see
http://msdn.microsoft.com/en-us/library/ms944772.aspx.

To connect other database software via ODBC connection string, you need to
consult corresponding vendor company.

//////////////////////////////////////////////////////////////

OLEDB ADO.NET Connection:
For SQL Server:
You can use such an OLEDB connection string to connect the database:
"Provider=SQLOLEDB;Data Source=***.***.***.***(IP address),****(port
number);Initial Catalog=DatabaseName;User ID=***;Password=***".

For IBM DB2:
Here are the keywords in the connection string:
Keyword "Network Transport Library=TCPIP" for TCP/IP connection
Keyword "Network Address=***.***.***.***" for IP address
For detail, please see http://www.connectionstrings.com/ibm-db2.

To connect other database software via OLEDB connection string, you need to
consult corresponding vendor company.

//////////////////////////////////////////////////////////////

For the third question about other vendors' connection string, please
understand that is not supported in Microsoft Newsgroup Supporting service.
You may consult the corresponding vendor company for the answer.

If you have any other questions, please be free to let me know. Have a
nice day, David!


Regards,
Lingzhi Sun (v-(E-Mail Removed), remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Lingzhi Sun [MSFT]
Guest
Posts: n/a
 
      17th Mar 2009
Hello David,

In this post, I'd like to discuss with you the three new questions that you
asked. If there is any misunderstanding, please be free to correct me.

///////////////////////////////////////////////////////////////////////////

Question 1: Does this connection string, "Data
Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial
Catalog=myDataBase;User ID=myUsername;Password=myPassword;" only work in
SQL Server 2008?

No, it is also supported in SQL Server 2005. You can refer to
http://www.connectionstrings.com/sql-server-2005 for additional
information.

///////////////////////////////////////////////////////////////////////////

Question 2: Should it be the "Network Library" attribute or the "Network"
attribute to set network protocol in SqlConnection, OdbcConnection and
OleDbConnection?

It is the "Network Library" attribute that determines the network protocol
used in the database connection string.

Here are some examples for SqlConnection, OdbcConnection and
OleDbConnection respectively. All the examples below work for SQL Server
2005 and SQL Server 2008. For other database software, please consult the
corresponding vendor company.

SqlConnection:
You can use such a connection string to create SqlConnection: "Data
Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial
Catalog=myDataBase;User ID=myUsername;Password=myPassword;".

DBMSSOCN is for TCP/IP, and DBNMPNTW for Named Pipes. For additional
information, please see
http://www.connectionstrings.com/Art...er-network-pro
tocol.

OdbcConnection:
You can use such a connection string to create OdbcConnection: "Driver={SQL
Server};Network Library=TCPIP;Server=190.190.200.100,1433;Database=
myDataBase;Uid= myUsername;Pwd= myPassword "

OleDbConnection:
You can use such a connection string to create OleDbConnection:
"Provider=SQLOLEDB;Data Source=190.190.200.100,1433;Network
Library=DBMSSOCN;Initial Catalog= myDataBase;User ID= myUsername;Password=
myPassword".

///////////////////////////////////////////////////////////////////////////

Question 3: How to determine if we enter an IP address or a server name in
the connection string?

I think it can be determined by regex for IP address. For detail, please
check http://www.regular-expressions.info/examples.html and
http://www.regular-expressions.info/...paccurate.html for IPv4 IP
address, and http://regexlib.com/REDetails.aspx?regexp_id=1115 for IPv6 IP
address.


If you have any other questions, please be free to let me know.


Regards,
Lingzhi Sun (v-(E-Mail Removed), remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

 
Reply With Quote
 
David Thielen
Guest
Posts: n/a
 
      17th Mar 2009
thank you very much.


On Tue, 17 Mar 2009 12:57:19 GMT, v-(E-Mail Removed)
(Lingzhi Sun [MSFT]) wrote:

>Hello David,
>
>In this post, I'd like to discuss with you the three new questions that you
>asked. If there is any misunderstanding, please be free to correct me.
>
>///////////////////////////////////////////////////////////////////////////
>
>Question 1: Does this connection string, "Data
>Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial
>Catalog=myDataBase;User ID=myUsername;Password=myPassword;" only work in
>SQL Server 2008?
>
>No, it is also supported in SQL Server 2005. You can refer to
>http://www.connectionstrings.com/sql-server-2005 for additional
>information.
>
>///////////////////////////////////////////////////////////////////////////
>
>Question 2: Should it be the "Network Library" attribute or the "Network"
>attribute to set network protocol in SqlConnection, OdbcConnection and
>OleDbConnection?
>
>It is the "Network Library" attribute that determines the network protocol
>used in the database connection string.
>
>Here are some examples for SqlConnection, OdbcConnection and
>OleDbConnection respectively. All the examples below work for SQL Server
>2005 and SQL Server 2008. For other database software, please consult the
>corresponding vendor company.
>
>SqlConnection:
>You can use such a connection string to create SqlConnection: "Data
>Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial
>Catalog=myDataBase;User ID=myUsername;Password=myPassword;".
>
>DBMSSOCN is for TCP/IP, and DBNMPNTW for Named Pipes. For additional
>information, please see
>http://www.connectionstrings.com/Art...er-network-pro
>tocol.
>
>OdbcConnection:
>You can use such a connection string to create OdbcConnection: "Driver={SQL
>Server};Network Library=TCPIP;Server=190.190.200.100,1433;Database=
>myDataBase;Uid= myUsername;Pwd= myPassword "
>
>OleDbConnection:
>You can use such a connection string to create OleDbConnection:
>"Provider=SQLOLEDB;Data Source=190.190.200.100,1433;Network
>Library=DBMSSOCN;Initial Catalog= myDataBase;User ID= myUsername;Password=
>myPassword".
>
>///////////////////////////////////////////////////////////////////////////
>
>Question 3: How to determine if we enter an IP address or a server name in
>the connection string?
>
>I think it can be determined by regex for IP address. For detail, please
>check http://www.regular-expressions.info/examples.html and
>http://www.regular-expressions.info/...paccurate.html for IPv4 IP
>address, and http://regexlib.com/REDetails.aspx?regexp_id=1115 for IPv6 IP
>address.
>
>
>If you have any other questions, please be free to let me know.
>
>
>Regards,
>Lingzhi Sun (v-(E-Mail Removed), remove 'online.')
>Microsoft Online Community Support
>
>=================================================
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>(E-Mail Removed).
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>=================================================



david@at-at-(E-Mail Removed)
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft VB .NET 0 8th Oct 2008 07:12 AM
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft Dot NET 0 8th Oct 2008 07:11 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com Microsoft ASP .NET 0 3rd May 2008 01:43 PM
when i am connecting vpn to client my system will not connecting server koteshsvv@gmail.com Microsoft Windows 2000 RAS Routing 1 24th Mar 2007 02:11 PM
Troubleshoot connecting client to SQL Server instance on a server John Hackert Microsoft Access ADP SQL Server 6 31st Jan 2007 10:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 PM.