无法将类型“int”隐式转换为“System.Data.SqlClient.SqlDataReader”?怎么解决?

ghost7889 2011-09-22 09:08:31
如题、以下为代码:
for (int i = 0; i <= dataGridView1.Rows.Count; i++)
{
for (int j = 1; j <= dataGridView1.Rows.Count - 1; j++)
{
string Department_sql = "update B3P3C_Parameters set B3P3C_Parameters_Department='" + department[i] + "' where B3P3C_Row= ‘" + j + "’";
m_reader = m_dbclass.ExcuteOneSQL(Department_sql);

}


}
...全文
150 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
haihuan23 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 qiume 的回复:]

m_reader 为 System.Data.SqlClient.SqlDataReader 类型,
而 m_dbclass.ExcuteOneSQL(Department_sql)返回 int 类型,
将m_reader改为 int 类型......
[/Quote]
+1
az10000nq 2011-09-22
  • 打赏
  • 举报
回复
学习,谢谢~
hudenq 2011-09-22
  • 打赏
  • 举报
回复
UPDATE语句为什么要给m_reader附值?
直接执行
m_dbclass.ExecuteNonQuery();不行么?
诺维斯基 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wnyxy 的回复:]
m_dbclass.ExcuteOneSQL(Department_sql);返回的是int


m_reader是SqlDataReader吧
[/Quote]
能转化吗?
我姓区不姓区 2011-09-22
  • 打赏
  • 举报
回复
department是什么东西?
十二点咖啡 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ghost5216 的回复:]
m_reader = m_dbclass.ExcuteOneSQL(Department_sql);
update 执行完返回的是一个int表示影响的行数
你m_reader 是SqlDataReader类型不匹配啊

int count =m_dbclass.ExcuteOneSQL(Department_sql);


我和楼主的用户ID很像
[/Quote]
+1
qiume 2011-09-22
  • 打赏
  • 举报
回复
m_reader 为 System.Data.SqlClient.SqlDataReader 类型,
而 m_dbclass.ExcuteOneSQL(Department_sql)返回 int 类型,
将m_reader改为 int 类型......
pgxuser 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ghost5216 的回复:]
m_reader = m_dbclass.ExcuteOneSQL(Department_sql);
update 执行完返回的是一个int表示影响的行数
你m_reader 是SqlDataReader类型不匹配啊

int count =m_dbclass.ExcuteOneSQL(Department_sql);


我和楼主的用户ID很像
[/Quote]
很可能就是这个原因!
ghost7889 2011-09-22
  • 打赏
  • 举报
回复
to 农民:
我知道 但是应该怎么修改啊
ghost5216 2011-09-22
  • 打赏
  • 举报
回复
m_reader = m_dbclass.ExcuteOneSQL(Department_sql);
update 执行完返回的是一个int表示影响的行数
你m_reader 是SqlDataReader类型不匹配啊

int count =m_dbclass.ExcuteOneSQL(Department_sql);


我和楼主的用户ID很像
pgxuser 2011-09-22
  • 打赏
  • 举报
回复
把这个方法全部贴出来
wnyxy001 2011-09-22
  • 打赏
  • 举报
回复
m_dbclass.ExcuteOneSQL(Department_sql);返回的是int


m_reader是SqlDataReader吧
ghost7889 2011-09-22
  • 打赏
  • 举报
回复
嗯 我知道 但是我不清楚怎么强制转换啊、、、返回类型是int型的 、、
Icedmilk 2011-09-22
  • 打赏
  • 举报
回复
C#是强类型语言,这种错误太好改了

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧