连接数据库
时间:2014-05-21 21:37:07
收藏:0
阅读:369
using System.Data.SqlClient;
static void Main(string[] args) { string connString = @"Data Source=.; Initial Catalog=lh0216; User ID=sa;pwd=Founder123"; //出了using括号objConnection类会被自动释放 using (SqlConnection objConnection = new SqlConnection(connString)) { objConnection.Open(); Console.WriteLine("数据库连接成功。"); } Console.ReadKey(); }
评论(0)