连接到SQL Server数据库的最佳方法
问题描述:
什么是连接到sql server数据库的最佳方法.
需要一种不适合初学者的专业方式
请举一个例子
问候
what is the best way to connect to sql server database.
need a professional way not for beginner
please give an example
regards
答
这很有意义:
通过C#访问SQL Server的入门指南 [ ^ ]
This sould go a long way:
Beginners guide to accessing SQL Server through C#[^]
SqlConnection conn=null;
try
{
String strConnection = String.Empty;
strConnection = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ToString();
using (conn = new SqlConnection(strConnection))
{
//code here
}
}
catch (Exception ex)
{
}
finally
{
conn.Close();
conn = null;
}
谢谢,
Thanks,
在我已经在此处回复您时重新发送邮件的任何具体原因: ^ ]
请避免转发.
Any specific reason for repost when I already replied you here: SQL server connection[^]
Please avoid reposts.