日期:2014-05-17 浏览次数:20845 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; namespace connectionSql { class Program { static void Main(string[] args) { SqlConnection myConnection; string connStr = "data source=.\\SQLEXPRESS;initial catalog=emotion;user id=saberrl;password=saberrl"; myConnection = new SqlConnection(connStr); try { myConnection.Open(); } catch (Exception e) { Console.WriteLine("{0}Secondn exception caught.", e); Console.ReadLine(); } Console.WriteLine("连接成功!"); myConnection.Close(); Console.ReadLine(); } } }