// using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=
//C:\Users\lhl\documents\visual studio 2010\projects\1111\1\Database1.mdf;Integrated Security=True;User Instance=True"))
// {
// conn.Open();
// using (SqlCommand cmd = conn.CreateCommand())
// {
// cmd.CommandText = "select * from T_Users";//c从表中读取数据、、、、
// using (SqlDataReader reader = cmd.ExecuteReader())
// {
// while (reader.Read())
// {
// string username = reader.GetString(reader.GetOrdinal("username"));
// int id = reader.GetInt32(reader.GetOrdinal("id"));
// string password = reader.GetString(reader.GetOrdinal("password"));
// Console.WriteLine("ID={0},名字={1},密码={2}",id,username,password);
// }
// }
// cmd.ExecuteNonQuery();
// Console.WriteLine("插入成功");
// }
// }
reader.GetOrdinal 怎么理解
|