What should I do to connect to MySql?
string constr = "Data Source=steve-pc;Initial Catalog=itcast2014;Integrated Security=True";
using (SqlConnection con = new SqlConnection(constr))
{
string sql = "select count(*) from TblPerson";
using (SqlCommand cmd = new SqlCommand(sql, con))
{
con.Open();
//object count = (int)cmd.ExecuteScalar();
object count = Convert.ToInt32(cmd.ExecuteScalar());
Console.WriteLine("TblPerson表中共有{0}条数据。", count);
}
}