当前窗体加载SQL table表 有table1 table2 窗体打开后就自动定位到saltable表table1的第一行 然后去查找table2中符合uuid的行,如有就下载对应的附件
红色部分代码运行提示无法将类型为“System.Int32”的对象强制转换为类型“Foxtable.Row”
如果改成
Dim bb As Integer = Tables(e.form.name & "_table2").Findrow("uuid='" & Tables(e.form.name & "_table1").Current("uuid") & "'")
If bb >0 Then '如果找到对应uuid的附件
不报错,但是没有达到预期效果。
有没有办法修正,并实现后续代码的类似运行。
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.1.30.2
错误所在事件:窗口,会议主体,定位第一行,Click
详细错误信息:
无法将类型为“System.Int32”的对象强制转换为类型“Foxtable.Row”。
代码内容:【尽管报错,但是预期效果实现,有没有办法修正错误,预期效果不变】
Dim zs1 As Integer = Tables(e.form.name & "_table1").Count
If zs1 >0 Then
Tables(e.form.name & "_table1").Position = 0 '定位到第一行
If Tables(e.form.name & "_table1").Current("uuid")<>"" Then '如果表1的uuid不为空
vars("第一行uuid")=Tables(e.form.name & "_table1").Current("uuid") '获取第一行uuid
Dim zs2 As Integer = Tables(e.form.name & "_table2").Count
If zs2 >0 Then '如果表2数据不为空
Dim bb As Row = Tables(e.form.name & "_table2").Findrow("uuid='" & Tables(e.form.name & "_table1").Current("uuid") & "'")
If bb IsNot Nothing Then '如果找到对应uuid的附件
Dim lst As List(of String)
lst = Tables(e.form.name & "_table2").Current.DataRow.Lines("文件名")
vars("文件名")=lst(0)
Dim dr As DataRow = Tables(e.form.name & "_table2").Current.DataRow
Dim fl As String = ProjectPath & "下载文件\第一行文件" & lst(0)
If Tables(e.form.name & "_table2").Current Is Nothing Then
vars("第一行文件地址")=""
Return
End If
If FileSys.FileExists(fl) AndAlso CRCCheckFile(fl) = dr.SQLGetValue("CRC值") Then '如果本地存在同名文件且CRC校验值相同
'则直接使用本地文件
Else '否则从数据库提取文件
If dr.SQLLoadFile("附件",fl) = False Then '如果提取文件失败
Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
End If
vars("第一行文件地址")=fl
End If
End If
End If
End If