Dim tb1 As Table = e.Form.Controls("Table1").Table
Dim tb2 As Table = e.Form.Controls("Table2").Table
Dim xb As Boolean
If e.Form.Controls("ComboBox3").Text = "男" Then
xb = False
Else
xb = True
End If
Dim cmd As New S QLCommand
cmd.C
Try
cmd.BeginTransaction() '开启事务
cmd.CommandText = "S ELECT * From {BAAB} where BAAB00 Is Null "
Dim dt As DataTable = cmd.ExecuteReader(True)
Dim dr As DataRow = dt.S QLFind("BAAB00 Is Null","[_Identify]")
If dr Is Nothing Then
dr = dt.AddNew
End If
dr("BAAB00") = Functions.Execute("X00序列号生成器_带前缀","BAAB","BAAB00","BAAB")
dr("BAAB01") = e.Form.Controls("DateTimePicker1").Text
dr("BAAB02") = e.Form.Controls("ComboBox2").Text
dr("BAAB03") = e.Form.Controls("ComboBox1").Text
dr("BAAB04") = e.Form.Controls("TextBox1").Text
dr("BAAB05") = xb
dr("BAAB06") = e.Form.Controls("NumericComboBox1").Text
dr("BAAB07") = e.Form.Controls("ComboBox4").Text
dr("BAAB08") = Functions.Execute("X00序列号生成器_带前缀","BAAB","BAAB08","BAAB")
dr("BAAB09") = e.Form.Controls("TextBox2").Text
dr("BAAB10") = Functions.Execute("X00序列号生成器_带前缀","BAAB","BAAB10","BAAB")
dr("BAAB11") = e.Form.Controls("TextBox3").Text
dr.Save()
Dim lm As String = dr("BAAB00")
Dim lx As String = dr("BAAB08")
Dim wj As String = dr("BAAB10")
cmd.CommandText = "S ELECT * From {ACAB} where ACAB01 = '" & lx & "'"
Dim dt1 As DataTable = cmd.ExecuteReader(True)
Dim dr1 As DataRow
For Each dr1 In dt1.DataRows
Dim tr As DataRow = tb1.DataTable.Find("_Identify = '" & dr1("_Identify") & "'")
If tr Is Nothing Then
dr1("ACAB00") = Nothing
dr1("ACAB01") = Nothing
dr1("ACAB02") = Nothing
dr1("ACAB03") = Nothing
dr1("ACAB04") = Nothing
dr1.Save()
End If
Next
For Each tr As DataRow In tb1.DataTable.DataRows
If tr.IsNull("ACAB00") = False Then
dr1 = dt1.S QLFind("[_Identify] = '" & tr("_Identify") & "'")
If dr1 Is Nothing Then
dr1 = dt1.S QLFind("ACAB00 Is Null")
If dr1 Is Nothing Then
dr1 = dt1.AddNew
End If
dr1("ACAB00") = Functions.Execute("X00序列号生成器_带前缀","ACAB","ACAB00","ACAB")
dr1("ACAB01") = lx
dr1("ACAB02") = tr("ACAB02")
dr1("ACAB03") = tr("ACAB03")
dr1("ACAB04") = "投递简历"
dr1.Save()
End If
End If
Next
cmd.CommandText = "SE LECT * From {ADAC} where [_Identify] is null"
Dim dt2 As DataTable = cmd.ExecuteReader(True) '生产datatable表,并传递给"dt"表
Dim dr2 As DataRow
cmd.CommandText = "SE LECT * From {ADAD} where [_Identify] is null"
Dim dt3 As DataTable = cmd.ExecuteReader(True) '生产datatable表,并传递给"dt"表
Dim dr3 As DataRow
For Each tr As DataRow In tb2.DataTable.DataRows
Dim fl As String = tr("ADAC04") '定义传递参数(含路径文件名)
dr2 = dt2.S QLFind("ADAC00 IS NULL","_Identify")
If dr2 Is Nothing Then
dr2 = dt2.AddNew
End If
dr2("ADAC00") = Functions.Execute("X01序列号生成器_简略版","ADAC") 'ID赋值
dr2("ADAC01") = wj '文件ID赋值
dr2("ADAC03") = FileSys.GetName(fl) '文件名赋值
dr2("ADAC04") = FileSys.GetName(fl) '显示名赋值
Dim t2 As Integer = 0 '定义序列号累计数值
If FileSys.FileExists(fl) Then
dr3 = dt3.S QLFind("ADAD02 = '" & CRCCheckFile(fl) & "'") '查找相同文件的行
If dr3 Is Nothing '如果没有相同文件的行
dr3 = dt3.SQ LFind("ADAD00 Is Null")
If dr3 Is Nothing
dr3 = dt3.AddNew '加一行
End If
dr3("ADAD00") = Functions.Execute("X01序列号生成器_简略版","ADAD") 'ID赋值
End If
dr2("ADAC02") = dr3("ADAC00") '附件ID赋值
Else
MessageBox.Show("文件不存在或路径/文件名错误,请核对后再添加!")
'cmd.Rollback() '则回滚事务
End If
dr2.Save()
dr3("ADAD01") = fl.SubString(fl.LastIndexOf(".") + 1) '提取文件扩展名并赋值给扩展名
dr3("ADAD02") = CRCCheckFile(fl) 'CRC赋值
dr3.Save()
dr3.S QLInsertFile("ADAD03",fl) '插入文件
dr3.Save()
'If bz1 = False AndAlso dt.HasChanges Then
'MessageBox.Show("保存失败,请于管理员联系!","保存失败!")
'cmd.Rollback() '则回滚事务
'Else If dt1.HasChanges OrElse dt2.HasChanges Then '如果任何一个表保存失败
'MessageBox.Show("保存失败,请于管理员联系!","保存失败!")
'cmd.Rollback() '则回滚事务
'End If
Next
cmd.Commit() '提交事务
'e.Form.Close()
Catch ex As Exception '如果出错
cmd.Rollback() '则回滚事务
MessageBox.Show(ex.Message, "错误",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
一旦运行就报错
此主题相关图片如下:微信图片_20210111205722.png
然后重启项目,删除bin文件夹,又可以用了,但是一会又报错了
然后又多了一个报错:
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.5.29.8
错误所在事件:窗口,010002 简历登记,Button2,Click
详细错误信息:
此 OleDbTransaction 已完成;它再也无法使用。
[此贴子已经被作者于2021/1/11 21:51:09编辑过]