buaa21 / summer2020

软件学院《程序设计实践》2020小学期仓库
40 stars 8 forks source link

winform 在数据库中查找时出现问题 #222

Closed Z8232000 closed 4 years ago

Z8232000 commented 4 years ago

怎样将查找到的int类型的数据输出在一个label里? 在调试中,对语句score = (int)reader["scores"]; 显示“指定的转换无效“ (数据库里scores是int型的)

crclz commented 4 years ago
  1. 把详细报错信息贴出来
  2. 可以尝试 Int.Parse( reader[...].ToString() )
  3. 可以使用Dapper来简化数据库访问 https://github.com/StackExchange/Dapper