如何连接sqlserver [英] How to connect sqlserver

查看:101
本文介绍了如何连接sqlserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用用户名和密码连接sqlserver

how to connect sqlserver, using username and password

推荐答案

好吧,通过使用连接字符串 [^ ]!

上面的链接提供了有关连接字符串的所有信息.可以在这里阅读有关数据通信的更多信息:使用ADO.NET访问数据 [ ^ ]
Well, by using a Connection String[^]!

The link above provides all info about connection string. Further info regarding the data communication can be read here: Accessing data with ADO.NET[^]


SqlConnection conn = new SqlConnection("server=localhost;database=DB_NAME;uid=sa;pwd=1234567");

SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM TABLE_NAME",conn);

DataTable dt = new DataTable();
adapter.Fill(dt)




完成了一个期间创建的连接,并将sql中的数据填充到C#中的datatable中. :-O




Completed a period created connection and fill data from sql to datatable in C#. :-O


这篇关于如何连接sqlserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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