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函数。