如何使用Con方法从本地计算机连接服务器Sql数据库? [英] How can i connect server Sql Database from my Local Machine by using Con method?

查看:77
本文介绍了如何使用Con方法从本地计算机连接服务器Sql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用.net中的con方法更新本地机器数据库。

现在我想更新服务器端数据库(本地机器中的同一个表)通过使用相同的程序..

i知道服务器数据库用户名,数据库名称,密码,表名..

请有人帮我解决这个问题....并给我语法...

Hi,
am updating local machine database by using con method in .net..
now i want to update server side database(same table in local machine) by using same program..
i know the server database username,database name,password,table name ..
please anyone help me regarding this....and give me the syntax...

推荐答案

什么是con方法?我从来没有听说过它。



无论如何,改变连接字符串很简单。您可以在 http://www.connectionstrings.com/ 找到大量示例和连接字符串格式[ ^ ]。您需要知道的是您要连接的数据库引擎类型以及您用于连接的技术。
What is "con method"?? I've never heard of it.

In any case, it's a simple matter of changing your connection string. You can find a ton of examples and connection string formats at http://www.connectionstrings.com/[^]. All you need to know is what kind of database engine you're connecting to and which technology you're using to connect.


您好Kumar,



如果你想更新服务器数据库,那么你需要在这样的连接字符串中使用服务器端数据库

Hi Kumar,

If you want to update server database, then you need to use server side database in connection string like this
SqlConnection conn = new SqlConnection("user Id=rk.prabakar; Password=rk.prabakar; server=192.168.1.XX\SQL2008R2; Database=TestDatabase;");





替换服务器名称使用您要更新的实际服务器名称。

服务器SQL实例名称可能类似于 192.XX.XX.XXX/SQLServer (使用ip地址和sql实例名称)

使用用于连接远程数据库的用户名和密码更改用户ID和密码



希望这个帮助你一点。



问候,

RK



Replace the server name with your actual server name that you intend to update.
Server SQL instance name may be like 192.XX.XX.XXX/SQLServer (comes with ip address and sql instance name)
Change userid and password with your username and password that is used to connect remote database

Hope this helps you a bit.

Regards,
RK


SqlConnection conn = new SqlConnection("user Id=aaa; Password=********; server=abc.de.fgh.ij/SqlExpress; Database=xyz;");



错了。



更好:


is wrong.

Better:

SqlConnection conn = new SqlConnection("user Id=aaa; Password=********; server=abc.de.fgh.ij\\SqlExpress; Database=xyz;");






OR

SqlConnection conn = new SqlConnection(@"user Id=aaa; Password=********; server=abc.de.fgh.ij\SqlExpress; Database=xyz;");


这篇关于如何使用Con方法从本地计算机连接服务器Sql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆