请任何人帮助连接网络sqlserver [英] Please anybody help to connecting networking sqlserver
问题描述
我想从联网的sql服务器访问数据库,所以我给出以下编码它不起作用
I want to access database from networking sql server so i give the following coding It was not working
Public con As New SqlConnection("Data Source=SQLSERVER\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=phoneix;User Id=sa;Password=welcome;")
Public con As New SqlConnection("Data Source=192.170.1.9,1433;Initial Catalog=phoneix;User Id=sa;Password=welcome;")
请为这个论坛提供帮助
在此先感谢
Please help for this forum
Thanks in Advance
推荐答案
检查是否允许远程连接.
允许远程连接
然后使用
Check whether you allow remote connection or not.
Allow Remote connection
and then use
<add key=""con"" value=""Data" source="10.11.1.13;Initial" catalog="omx;Persist" security="" info="True;"/"></add>
以下解决方案之一将为您提供帮助,
1)将sql server端口添加到连接字符串中:
one of the following solution will help you ,
1)Add the sql server port to the connection string:
Server=YourSQLSRVR,10000;Database=YourDatabase;User ID=User;Password=?????????
2)
1.您的SQl浏览器已关闭
2. SQLServer Configuration Manager中的协议> SQL Server 2005网络配置> SQL Express的协议(例如TCP/IP,命名管道)已禁用.
分辨率.
只需启动SQL Browser.
启用协议.
重新启动SQL Express服务.
3)您的电脑名称\ SQLEXPRESS
u复制此名称并将其粘贴为asp.net框架的Web配置文件为
2)
1. Your SQl Browser is off
2. Protocols under SQLServer Configuration Manager > SQL Server 2005 Network Configuration > Protocols for SQL Express like TCP/IP, Named Pipes are disabled.
Resolution.
Just Start SQL Browser.
Enable the Protocols.
Restart SQL Express service.
3)your pc name\SQLEXPRESS
u copy this name and paste it in the web config file of your asp.net framework as
<connectionStrings>
<add name="this name is as your wish" connectionString="server=your pc name\\SQLEXPRESS; catalog= your database name;SSPI=true; providerName="System.Data.SqlClient" "/>
</connectionString>
this section comes under <appSettings/>
然后您在您的aspx.cs代码文件中将此字符串连接称为
then u call this string connection in ur aspx.cs code file as
// Create the Connection object.
string connectionString =
WebConfigurationManager.ConnectionStrings["this name is as your wish"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
然后您打开连接并按您的目的使用,并确保使用后关闭连接
我希望这可以解决问题
then u open the connection and use for your purpose and make sure that u close the connection after use
I hope this might resolve the problem
这篇关于请任何人帮助连接网络sqlserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!