//很简单,但是,久了不用了就会遗忘,记下来以后重用
string str = Properties.Settings.Default.StudentConnectionString;//连接字符串
SqlConnection conn = new SqlConnection(str);//构造数据库连接SqlCommand cmd = conn.CreateCommand();//构造数据库cmd
conn.Open();
cmd.CommandText="select count(*) from Core";
SqlDataReader rd = cmd.ExecuteReader();
while(rd.Read())
{
Console.WriteLine(rd[0]);
}