try
Connections(_strBooks).BeginTransaction()
e.Form.BaseForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
e.Form.DisableXButton()
Dim ma As String
Dim fo As WinForm.Form = Forms("金相BusMain")
If fo.Opened Then
Dim lvw As WinForm.ListView = Forms("金相BusMain").Controls("LV_SCXX")
Dim vr As WinForm.ListViewRow = lvw.Current '获取ListView中选定的行
If vr Is Nothing Then '如果不存在当前行,也就是内有选定任何一行
Return
End If
Dim dr As DataRow = vr.tag '获取此行对应的DataRow
e.Form.Controls("TXT_MO").Text = dr("制令单号")
e.Form.Controls("TXT_TI").text=dr("送检单号")
e.Form.Controls("TXT_PRDNAME").Text = dr("货品名称")
e.Form.Controls("TXT_DEP").text=dr("生产线")
e.Form.Controls("TXT_JLNO").text=Vars("_jxlv_jl")
Vars("_jxlv_prdno")=dr("货品编号")
End If
''获得检验项目
''建立表
Dim s As String = Guid.NewGuid.ToString()
Dim cmd1 As new SQLCommand
cmd1.ConnectionName=_strBooks
cmd1.CommandText="EXEC GET_PROJECT_JY '" & _t1 & "','" & Vars("_jxlv_prdno") & "','" & Date.Now() & "','" & s & "'"
cmd1.ExecuteNonQuery()
''MessageBox.Show("建立了表成功")
Dim q As new QueryBuilder
q.TableName = "金相临时"
q.ConnectionName=_strBooks
q.SelectString="exec GET_PROJECT_SHOW_TABLE '" & s & "'"
q.Build
''MessageBox.Show("查询了表成功")
Dim i As Integer
i=Tables("金相临时").Cols.Count
Vars("_int_tbcount")=i
Dim j As Integer
For j=0 To i-1
Tables("金相临时").Cols(j).RecordRowHeight=2
Next
''Tables("金相临时").Cols(0).RecordRowHeight=2
Dim rgd As WinForm.RecordGrid = e.Form.Controls("RCDG_R")
Tables("金相临时").AllowEdit=True
rgd.Table=Tables("金相临时")
rgd.Build
''删除表
Dim cmd4 As new SQLCommand
cmd4.ConnectionName=_strBooks
cmd4.CommandText="exec GET_PROJECT_DROP_TABLE '" & s & "'"
cmd4.ExecuteNonQuery()
Connections(_strBooks).Commit
catch ex As exception
Connections(_strBooks).Rollback()
MessageBox.Show(ex.Tostring())
End try
然后出错了:
如果分配给命令的连接位于本地挂起事务中,excutereader要求命令拥有事务。命令的transaction属性尚未初始化。