连接到SQL Server数据库的最佳方法 [英] best way to connect to sql server database

查看:73
本文介绍了连接到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.


这篇关于连接到SQL Server数据库的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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