本文介绍了无法将“System.Data.DataRow”类型的对象强制转换为“System.IConvertible”类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!我收到此错误。 这是代码: Dim conn As SqlConnection = 新 SqlConnection( "数据源= E5D603;初始值Catalog = CashReceipt; Integrated Security = True" )I'm getting this error. Here is the code:Dim conn As SqlConnection = New SqlConnection("Data Source=E5D603;Initial Catalog=CashReceipt;Integrated Security=True") Dim RDataSet As 新 数据集Dim RDataSet As New DataSet Dim RfileAdapter As SqlDataAdapter = 新 SqlDataAdapter( " select * from tbl_AccDetails&qu ot; ,conn)Dim RfileAdapter As SqlDataAdapter = New SqlDataAdapter("select * from tbl_AccDetails", conn) RfileAdapter.FillSchema(RDataSet,SchemaType.Source, " tbl_AccDetails" )RfileAdapter.FillSchema(RDataSet, SchemaType.Source, "tbl_AccDetails") RfileAdapter.Fill(RDataSet)RfileAdapter.Fill(RDataSet) Dim RTbl As DataTable = RDataSet.Tables(0)Dim RTbl As DataTable = RDataSet.Tables(0) while oRead.EndOfStream = FalseWhile oRead.EndOfStream = False Dim oneLine As 字符串 = oRead.ReadLine() Dim TblRow = RTbl.NewRowDim oneLine As String = oRead.ReadLine()Dim TblRow = RTbl.NewRow TblRow(1)= Convert.ToString(LTrim(oneLine.Substring(30,30)) ))TblRow(1) = Convert.ToString(LTrim(oneLine.Substring(30, 30))) TblRow(2)= Convert.ToString(LTrim(oneLine.Subst) ring(0,10)))TblRow(2) = Convert.ToString(LTrim(oneLine.Substring(0, 10))) Dim LBal As String = LTrim(oneLine.Substring(16,12))Dim LBal As String = LTrim(oneLine.Substring(16, 12)) Dim myLBal =(LBal.Substring(0,9))Dim myLBal = (LBal.Substring(0, 9)) Dim mySign =(LBal.Substring(9,1))Dim mySign = (LBal.Substring(9, 1)) TblRow(3)= (CDec(mySign + myLBal))TblRow(3) = (CDec(mySign + myLBal)) Dim LWChg As 字符串 = LTrim(oneLine.Substring(65,10))Dim LWChg As String = LTrim(oneLine.Substring(65, 10)) Dim myLWChg =(LWChg.Substring(0,8))Dim myLWChg = (LWChg.Substring(0, 8)) Dim LWSign =(LWChg.Substring(8,1))Dim LWSign = (LWChg.Substring(8, 1)) 'TblRow(4)= ( CDec (LWSign + myLWChg))'TblRow(4) = (CDec(LWSign + myLWChg)) TblRow(5)= Convert.ToInt32(LTrim(oneLine.Substring(120,3)))TblRow(5) = Convert.ToInt32(LTrim(oneLine.Substring(120, 3))) TblRow (6)= Convert.ToString(LTrim(oneLine.Substring(124,29)))TblRow(6) = Convert.ToString(LTrim(oneLine.Substring(124, 29))) TblRow(7)= Convert.ToString(LTrim(oneLine.Substring(155,28)) ))TblRow(7) = Convert.ToString(LTrim(oneLine.Substring(155, 28))) RTbl.Rows.Add(TblRow)' ------------------这是错误行RTbl.Rows.Add(TblRow) '------------------ This is the line of error 我检查了表,它有正确的数据类型。我还检查了每个变量的内容,这也没问题。如果我省略这个RTbl.Rows.Add那么它就可以了。 有什么想法吗?Any idea guys? 谢谢提前推荐答案 任何人都可以看看这个问题并指出我正确的方向。Can anyone please take a look at this problem and point me to correct directions.谢谢 这篇关于无法将“System.Data.DataRow”类型的对象强制转换为“System.IConvertible”类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-29 17:43