在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//返回数组对象 public List<User> GetUser() {try { using (SqlConnection testConnection = new SqlConnection(ConnStr.connectionString)) { SqlCommand testCommand = testConnection.CreateCommand(); testCommand.CommandText = "select [id],[name] from [user]"; testConnection.Open(); List<User> users = new List<User>(); SqlDataReader rd = testCommand.ExecuteReader(); while (rd.Read())//read next { User userback = new User(); userback.ID = rd.GetInt32(0); userback.Name = rd.GetString(1); users.Add(userback); //add to list } Console.WriteLine("Back all sql User"); return users; } } catch (Exception e1) { Console.WriteLine(e1.Message); return null; } } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论