Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
下载信息 [文件大小: 下载次数: ] | |
![]() |
With DataTables("考试")
dr_xn = .Find("学年 ='" & xn & "'") '检查相同学年
dr_xq = .Find( "学期 ='" & xq.value & "'") '检查相同学期
dr_ksmc = .Find("考试名称 ='" & ksmc.value & "'") '检查相同考试名称
End With
If dr_ksmc Is Nothing Then
..............
为什么刚开始加考试表时找不到datatables("考试")中的考试名称等
代码作用是:发现输入考试信息与表中想同就提示已经存在,如果不同就生成新的考试信息
Dim xn2 As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim xq As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim ksmc As WinForm.TextBox = e.Form.Controls("TextBoxKSMC")
If xn2.value<>"" And xq.value<>"" And ksmc.value<>"" Then
Dim Result As DialogResult
result=MessageBox.Show("考试信息正确吗?","提示",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim xn As String
Dim dr_xn,dr_xq,dr_ksmc As DataRow
xn=e.Form.Controls("ComboBox1").Value & "-" & xn2.Value &"学年"
With DataTables("考试")
dr_xn = .Find("学年 ='" & xn & "'") '检查相同学年
dr_xq = .Find( "学期 ='" & xq.value & "'") '检查相同学期
dr_ksmc = .Find("考试名称 ='" & ksmc.value & "'")
End With
If dr_ksmc Is Nothing Then
MessageBox.Show("sdfas")
Dim f As New Filler
f.SourceTable = DataTables("信息") '指定数据来源
f.SourceCols = "id" '指定数据来源列
f.DataTable = DataTables("考试") '指定数据接收表 'f.ExcludeExistValue=True 'f.DataCols = "产品,客户" '指定数据接收列
f.Fill() '填充数
For Each r As Row In Tables("考试").Rows
r("学年")= xn
r("学期")= xq.value
r("考试名称") = ksmc.value
Next
Else
MessageBox.Show("本次考试信息已经存在!")
e.Cancel=True
End If
End If
Else
MessageBox.Show("考试信息不能为空!")
End If
你的代码我测试可以用呀.我加个了取消按钮
MessageBox.Show("本次考试信息已经存在!")
e.Cancel=True
用find方法没有成功,考虑到以后要用外部数据源把中间部分改了一下,测试通过
Dim xn,dr_ksmc As String
xn=e.Form.Controls("ComboBox1").Value & "-" & xn2.Value &"学年"
Dim cmd As New SQLCommand
cmd.CommandText = "Select 考试名称 From {考试} Where 学年 = '" & xn & "'" & "And 学期 = '" & xq.value & "'" & "And 考试名称 = '" & ksmc.value & "'"
dr_ksmc = cmd.ExecuteScalar()
If dr_ksmc = "" Then
Dim f As New Filler