从其他客户端连接到sql server2005 [英] Connecting to Sql server2005 from Other clients
问题描述
HI:困惑:
我有一个用C#编写的Win应用程序.
我的问题是从其他客户端连接到Sql server2005.
我写了另一个简单的程序来测试我的连接.我使用try-Catch打开连接,但无法打开连接.
我一直在搜索很多页面,但无法解决我的问题.
我使用了Two Button,这是我的项目:
http://www.4shared.com/file/HcKYuam_/IP_online.html [ ^ ]
我也有一个数据库(以Test的名义)和一个表(以Table_1的名义).
出什么事了吗还是我要调整一下.
请帮帮我
感谢
HI :confused:
I have a win app program that I wrote it in C#.
My problem Is connecting to Sql server2005 from Other clients.
I wrote Another simple program for testing my connection. I used try-Catch for opening connections But it can not Open connection.
I have been searching a lot of pages and I couldn''t solve my problem.
I used Two Button and it is my project:
http://www.4shared.com/file/HcKYuam_/IP_online.html[^]
Also I Have Database (in the name of Test) with one Table(in the name of Table_1).
Is it something wrong? Or I have to adjust something.
please Help me
thanks
推荐答案
您需要允许MS SQL Server进行远程连接,以便其他客户端可以访问它.请参阅此链接以获取步骤- http://support.microsoft.com/kb/914277 [
You need to allow remote connections for your MS SQL server, so that other clients could access it. Refer this link for steps - http://support.microsoft.com/kb/914277[^]
An important point to note - I guess you will distribute this application to others. So make sure you are not having the connection string in plain text. Encrypt the connection string/ the password when you distribute the app.
SqlConnection con =新的SqlConnection(服务器=服务器名;数据库=数据库名;集成安全性= true");
SqlCommand cmd =新的SqlCommand(您的插入查询",con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
SqlConnection con=new SqlConnection ("Server=servername;database=databasename;integrated security=true");
SqlCommand cmd=new SqlCommand ("your insert query",con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
在您的代码中,我可以清楚地看到您可能未使用ConnectionString
应该采用的格式.
请查看此 [
In your Code I can clearly see that you are probably not usingConnectionString
in which format it should be.
Please have a look at THIS[^] to have more clarity aboutConnectionString
to DB.
Please vote and Accept Answer if it Helped.
这篇关于从其他客户端连接到sql server2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!