static void Main(string[] args)
{
string connStr = @"server=.\sqlexpress;database=HeiMa8;uid=sa;pwd=123;";
string sql = "select id, uid, pwd from Exe2.LoginTbl;";
using (SqlConnection conn = new SqlConnection(connStr))
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
using (reader)
{
// conn.Close();
reader.Read();
DBNull dbnull = (DBNull)reader.GetValue(2);
object o = reader.IsDBNull(2) ? null : reader[2];
// 整数 int
// int n = null;
// int? num = reader.IsDBNull(0) ? null : (int?)reader.GetInt32(0);
}
}
}
Console.ReadKey();
}
{
string connStr = @"server=.\sqlexpress;database=HeiMa8;uid=sa;pwd=123;";
string sql = "select id, uid, pwd from Exe2.LoginTbl;";
using (SqlConnection conn = new SqlConnection(connStr))
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
using (reader)
{
// conn.Close();
reader.Read();
DBNull dbnull = (DBNull)reader.GetValue(2);
object o = reader.IsDBNull(2) ? null : reader[2];
// 整数 int
// int n = null;
// int? num = reader.IsDBNull(0) ? null : (int?)reader.GetInt32(0);
}
}
}
Console.ReadKey();
}