将varchar值'System.Data.DataRow'转换为数据类型int时转换失败 [英] Conversion failed when converting the varchar value 'System.Data.DataRow' to data type int

查看:196
本文介绍了将varchar值'System.Data.DataRow'转换为数据类型int时转换失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..

[将varchar值"System.Data.DataRow"转换为数据类型int时转换失败]

我陷入了那个错误..
这是我的代码.


Hello all..

[Conversion failed when converting the varchar value ''System.Data.DataRow'' to data type int]

i''m stuck with that error..
this is my code..


adapter = new SqlDataAdapter("SELECT result_date,student_ID,test_ID,correct_answer,false_answer,mark FROM RESULTS WHERE student_ID='" + selectedrow + "'", connect);
           dt = new DataTable();
               adapter.Fill(dt);
               resultDG.ItemsSource = dt.DefaultView;



selectedrow表示此>>



selectedrow mean this>>

private void stdlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           DataRowView selectedDRow = (DataRowView)stdlist.SelectedItem;
           selectedrow = selectedDRow.Row;
        }





为什么会出现此错误??
我该如何解决





why this error hppend.?
how can i fixi''t

推荐答案

selectedrow ^ ]类型,这意味着您不能直接将其连接为字符串.尝试从selectedrow(可能为selectedrow ["student_ID"])中检查所需值的正确索引.
selectedrow is a System.Data.DataRow[^] type, which means that you can''t directly concatenate it to a string. Try to check the right index of the value that you want from selectedrow (selectedrow["student_ID"] probably).


''&val(selectedrow.text)&"' '"
''" & val (selectedrow.text) & "''"


这篇关于将varchar值'System.Data.DataRow'转换为数据类型int时转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆