VB sql程序
这段程序COMMAND2的点击事件不执行DimcnAsNewADODB.Connection'通用声明DimrsAsNewADODB.RecordsetDimstrSQL...
这段程序COMMAND2的点击事件不执行
Dim cn As New ADODB.Connection '通用声明
Dim rs As New ADODB.Recordset
Dim strSQL As String
Private Sub Command2_Click() '下一题
rs.MoveNext
If rs.EOF Then
rs.MoveLast
End If
End Sub
Private Sub Command4_Click() '显示隐藏答案
Label6.Visible = True
Command4.Visible = False
Command6.Visible = True
End Sub
Private Sub Command5_Click() '开始
Frame1.Visible = True
End Sub
Private Sub Command6_Click() '显示隐藏答案
Label6.Visible = False
Command4.Visible = True
Command6.Visible = False
End Sub
Private Sub Form_Load()
Frame1.Visible = False
cn.Open "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=kssjk;Data Source=ONCE"
strSQL = " Select * From " & Trim(Combo1.Text) & " "
rs.Open strSQL, cn, adOpenStatic
Label8.Caption = rs("id")
Label4.Caption = rs("content")
Label5.Caption = rs("choice")
Label6.Caption = rs("answer")
Label6.Visible = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing
End Sub 展开
Dim cn As New ADODB.Connection '通用声明
Dim rs As New ADODB.Recordset
Dim strSQL As String
Private Sub Command2_Click() '下一题
rs.MoveNext
If rs.EOF Then
rs.MoveLast
End If
End Sub
Private Sub Command4_Click() '显示隐藏答案
Label6.Visible = True
Command4.Visible = False
Command6.Visible = True
End Sub
Private Sub Command5_Click() '开始
Frame1.Visible = True
End Sub
Private Sub Command6_Click() '显示隐藏答案
Label6.Visible = False
Command4.Visible = True
Command6.Visible = False
End Sub
Private Sub Form_Load()
Frame1.Visible = False
cn.Open "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=kssjk;Data Source=ONCE"
strSQL = " Select * From " & Trim(Combo1.Text) & " "
rs.Open strSQL, cn, adOpenStatic
Label8.Caption = rs("id")
Label4.Caption = rs("content")
Label5.Caption = rs("choice")
Label6.Caption = rs("answer")
Label6.Visible = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing
End Sub 展开
1个回答
展开全部
你的command2_click没问题,但你没有要显示内容啊。你应该这样:
Private Sub Command2_Click() '下一题
If rs.EOF Then
rs.MoveLast
Else
rs.MoveNext
End If
Label8.Caption = rs("id")
Label4.Caption = rs("content")
Label5.Caption = rs("choice")
Label6.Caption = rs("answer")
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询