方法1、另外建一个函数,一次性返回多个编号,大概
Dim bm As String = args(0)
Dim 行数 As integer = args(1)
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "s elect * from {编码表}"
Dim dt As DataTable = cmd.ExecuteReader(True)
Dim dr As DataRow = dt.Find("表名 ='" & bm & "'")
If dr IsNot Nothing Then
If Date.Today > dr("日期") Then '如果今天的日子大于存在表格里的日期
dr("日期") = Date.Today
dr("序号") = 行数
Else
dr("序号") = dr("序号") + 行数 '如果和今天的日子一样,则序号+1
End If
dr.Save
Return(dr("序号") + 1)
End If
-----------
……
DataTables("前台订房表").StopRedraw
dim 编号索引 as integer = Functions.Execute("数据表编号2", "前台订房表",crs.count)
For Each dr As DataRow In crs
Dim vr As DataRow = DataTables("前台订房表").AddNew
vr("SysId") = dr("前缀名") + Format(Date.Today, "yyMMdd") + Format(编号索引, "0000")
编号索引 = 编号索引 + 1
vr("营业日期") = yyrq
……
方法1、2个表如果在同一个数据库,建议使用存储过程处理