public static void Qr() {
string strConn = "Data Source=DESKTOP-QDQS9F8;Initial Catalog=QQ用户信息;User ID=sa;pwd =root";
SqlConnection conn = null;
SqlDataReader Reader = null;
try
{
conn = new SqlConnection(strConn);
conn.Open();
string sal = string.Format("select *from userinfo");
SqlCommand comm = new SqlCommand(strConn);
SqlCommand com = new SqlCommand(sal, conn);
Reader = com.ExecuteReader();
while (Reader.Read())
{
Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", Reader["UserId"], Reader["UserName"], Reader["levelId"], Reader["Email"], Reader["OnlinDay"]);
}
}
catch (Exception w) {
Console.WriteLine(w.Message);
}
finally
{
if (Reader != null) {
Reader.Close();
}
if (conn != null) {
conn.Close();
}
}