数据库查询出错 ,错误信息如下:
从字符串“SELECT NVL(W2.SCENE, 0) SCENE, ”到类型“Double”的转换无效。
请问是什么原因(原来的代码在数据库中能正常查询到结果,现在改为3个变量,从另外3张表中取3个数值,正常应该也没有什么问题吧)
Dim dt As DataTable
cmd.C
Dim sCols() As String = {"SCENE", "PROBLEM", "YZG","ZGL", "YBYH", "JDYH","ZDYH"}
Dim dCols() As String = {"SCENE", "PROBLEM", "YZG","ZGL", "YBYH", "JDYH","ZDYH"}
For Each r1 As Row In Tables("年份")
For Each r2 As Row In Tables("月份")
For Each r3 As Row In Tables("单位")
Dim S1 As String
S1 = "SELECT NVL(W2.SCENE, 0) SCENE,"
S1 = S1 + " NVL(WTZS, 0) PROBLEM,"
。。。。。。中间省去若干行
S1 = S1 + " ON 1 = 1"
cmd.CommandText = s1
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.DataRows
Dim nr As DataRow = DataTables("HSE_Problem_count").AddNew()
nr("年") = r1("YEARS")
nr("月") = r2("MONTHS")
nr("orgid") = r3("L2_ORG_ID")
nr("单位") = r3("L2_ORG_NAME")
For i As Integer =0 To sCols.Length -1
nr(dCols(i)) = dr(sCols(i))
Next
Next
Next
Next
Next
[此贴子已经被作者于2022/2/18 10:57:26编辑过]