sqlsever2008創建鏈接,執行命令sql
sql0 = "SELECT id,name,age FROM demo";//sql語句函數
/************************spa
創建鏈接server
************************/it
SqlConnection sqlConnection1 = new SqlConnection();io
sqlConnection1.ConnectionString = "server=localhost;user id=yuanming;password=123456;initial catalog=demo";sql語句
/***********************demo
打開sqlword
*************************/new
sqlConnection1.Open();
/***************************
執行命令
*****************************/
SqlCommand sqlCommand1 = new SqlCommand();
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = sql0;
而後調用sqkCommand執行相應execute函數。