关于数据读取器错误 [英] about data reader error
本文介绍了关于数据读取器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此行发生错误:-Label6.Text = reader [0];
无法将类型"object"隐式转换为"string".存在显式转换(您是否缺少演员表?)
我无法理解的错误是什么....帮助我..
Error Occure on this line:-Label6.Text = reader[0];
Cannot implicitly convert type ''object'' to ''string''. An explicit conversion exists (are you missing a cast?)
what is mistake i cant understand....help me..
推荐答案
您需要将读取器值转换为字符串.您不能直接将阅读器值分配给标签文本.
它应该是
You need to cast the reader value to string. You cannot directly assign reader value to label text.
It should be
Label6.Text = reader.getValue(0);
您缺少ToString().应该是:
You are missing the ToString(). It should be :
Label6.Text = reader[0].ToString();
Label6.Text = reader [0] .ToString()
Label6.Text = reader[0].ToString()
这篇关于关于数据读取器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文