我是在Delphi里通过连接字符串进行连接的,但是:
在许多机器上(主要是2000,98),必须先用\\机器名登陆一下对方,才可以通;这非常不方便,请问大家如何解决这个问题的;
用ODBC建立数据源来连接的时候,就没有此问题
-------------------------------------------------------------------------------
只要在连接字符串中添加Network Library=dbmssocn,指定使用TCP/IP协议连接即可。
参考MSDN:http://support.microsoft.com/kb/238949/en-us
MORE INFORMATION
SQL Server allows you to use the following network libraries when establishing a connection. They are:
• dbnmpntw - Win32 Named Pipes
• dbmssocn - Win32 Winsock TCP/IP
• dbmsspxn - Win32 SPX/IPX
• dbmsvinn - Win32 Banyan Vines
• dbmsrpcn - Win32 Multi-Protocol (Windows RPC)
When connecting to SQL Server through ADO the NETWORK parameter in the connection string can be used to specify which of these libraries to use when connecting to the database. The NETWORK parameter is the name of the Net-Library module to use, without the .dll suffix (for example, Dbmssocn, not Dbmssocn.dll). Here are some examples of connection strings that specify this parameter:
Note Make sure that User ID has the appropriate permissions to perform this operation on the database. • The following connection string:
"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=
1<user id="">;Initial Catalog=pubs;Data Source=<yourdatasourcename>;Network Library=dbnmpntw"
2
3tries to connect to SQL Server through the SQLOLEDB provider using the Named Pipes network library.
4• The following connection string:
5
6"Provider=MSDASQL.1;Persist Security Info=False;User ID=<user id="">;Extended Properties="DSN=<yourdatasourcename>;UID=<user id="">;DATABASE=pubs;Network Library=dbmssocn";Initial Catalog=pubs"
7
8connects to SQL Server through the MSDASQL provider using the TCP/IP network library.
9
10
11ADO的连接字符串相关参数还有:
12
13Network Address,指定IP地址和SQLServer的端口号,1433可以不写
14Trusted_Connection,是否使用信任连接
15……
16
17具体查看MSDN或SQLServer2000的联机帮助</user></yourdatasourcename></user></yourdatasourcename></user>