在C#中连接SQL数据库 [英] Connecting SQL Database in C#
本文介绍了在C#中连接SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好日子,
我有一个名为DBC.sql的SQl数据库。
我想要使用c#在windows窗体应用程序中连接它。
有人可以帮我编写代码吗?
Good days,
I have a SQl Database named DBC.sql.
I want to connect it in windows form aplication using c# .
can someone help me to make a code of this?
推荐答案
string connectionString =server =< servername> ;; database =< databasename> ;; integrated security = true;
using(SqlConnection cnn = new SqlConnection(cnnstringforWindowsAuth))
{
//您的代码在这里
}
string connectionString = "server=<servername>; database=<databasename>;integrated security=true;"
using (SqlConnection cnn = new SqlConnection(cnnstringforWindowsAuth))
{
// Your code here
}
这篇关于在C#中连接SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文