首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

VB下标越界如何改

2012-01-24 
VB下标越界怎么改Private Sub Form_Load()Dim SQL As StringDim rs As New ADODB.RecordsetIf flag 1 Th

VB下标越界怎么改
Private Sub Form_Load()
  Dim SQL As String
  Dim rs As New ADODB.Recordset
  If flag = 1 Then
  SQL = "select SID from 员工信息 order by SID"
  Set rs = TransactSQL(SQL)
  If rs.EOF = False Then
  rs.MoveFirst
  firstID = rs(0)
  While Not rs.EOF
  Me.YGID.AddItem rs(0) '初始化员工编号
  rs.MoveNext
  Wend
  rs.Close
  Else
  MsgBox "目前没有员工!", vbOKOnly + vbExclamation, "警告!"
  End If
  Me.NowDate = Date
  Me.YGID.ListIndex = 0
  SQL = "select SName from 员工信息 where SID='" & firstID & "'"
  Set rs = TransactSQL(SQL)
  Me.YGName = rs(0) '初始化员工姓名
  rs.Close
  Me.OutTime = ""
  Me.InTime = ""
  Else
  Me.Topic = "修改员工上下班信息"
  Set rs = TransactSQL(KQsql)
  If rs.EOF = False Then //这句错误
  With rs
  Me.YGID = rs(1)
  Me.YGName = rs(2)
  Me.NowDate = rs(3)
  If IsNull(rs(5)) = True Then
  Me.InTime = ""
  Me.OutFlag = True
  Else
  Me.InTime = rs(5)
  End If
  If IsNull(rs(6)) = True Then
  Me.OutTime = ""
  Me.InFlag = True
  Else
  Me.OutTime = rs(6)
  End If
  End With
  End If
  End If
End Sub

[解决办法]
没有查询到记录。

[解决办法]
去这个函数里面看看TransactSQL
[解决办法]
If rs.EOF = False Then 
改成这样试试:
if rs.recordcount>0 then

[解决办法]
KQsql如果没有查询语句
返回的rs可能为空

热点排行