Dim dr ,dr1,dr2,dr3 As DataRow
dr = DataTables("用户信息表").find (" name = '"& _username &"'")
Dim xx As String = dr("学校")
Dim qu As String = dr("区")
e.Form.Controls("区").text = qu
e.Form.Controls("学校").text = xx
e.Form.Controls("级别").text = dr("级别")
e.Form.Controls("辅导老师").text = dr("呢称")
dr1 = DataTables("学生信息表").find (" 区 = '"& qu &"' and 学校 = '"& xx &"'","学号",0)
If dr1 IsNot Nothing Then
Dim xh0 As String = dr1("学号").SubString(0,5)
For i As Integer = 1 To 999
Dim s As String = Format(i,"000")
Dim xh As String = xh0 & s
dr2 = DataTables("学生信息表").find (" 学号 = '"& xh &"'" )
If dr2 Is Nothing Then
e.Form.Controls("学号").text = xh
If MessageBox.Show("是否使用此注册号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)= DialogResult.Yes Then
Return
End If
End If
Next
Else
dr3 = DataTables("花名册").find ("地区名 = '"& qu &"'")
Dim x1 As String = dr3("编号")
Dim ss As List (of String) = DataTables("学生信息表").GetValues("学校","区 = '"& qu &"'")
Dim x2 As String = Format(ss.Count + 1,"000")
For i As Integer = 1 To 999
Dim x3 As String = Format(i,"000")
Dim xh As String = x1 & x2 & x3
dr2 = DataTables("学生信息表").find (" 学号 = '"& xh &"'" )
If dr2 Is Nothing Then
e.Form.Controls("学号").text = xh
If MessageBox.Show("是否使用此注册号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)= DialogResult.Yes Then
Return
End If
End If
Next
End If
以上是自动生成注册码的代码,运行测试正常。
但是把“学生信息表”定向为外部表后,必须加载“学生信息表”后才能正常运行,但正是使用时“学生信息表”会有几万行。
现向专家求助: 用SQL语言修改代码,让他在“学生信息表”未加载的情况下可以正常运行。
谢谢!!!