MSSQL:通过文本框浏览数据

11 篇文章 1 订阅


Dim Con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim i%

Private Sub Form_Load()
Con.ConnectionString = "Driver={sql server};server=wjpc;uid=sa;pwd=;database=db_2008"
Con.Open
Rs.Open "select * from aa", Con, adOpenKeyset, adLockOptimistic
Set MS1.DataSource = Rs
For i = 0 To 3
    Text1(i) = Rs.Fields(i)
Next
End Sub

Private Sub Cmd_first_Click()
If Rs.BOF <> True Then
    Rs.MoveFirst
    For i = 0 To 3
        Text1(i) = Rs.Fields(i)
    Next
End If
End Sub
Private Sub Cmd_up_Click()
On Error Resume Next
Rs.MovePrevious
If Rs.BOF Then
    Rs.MoveNext
    Exit Sub
Else
    For i = 0 To 3
        Text1(i) = Rs.Fields(i)
    Next
End If
End Sub


Private Sub Cmd_down_Click()
On Error Resume Next
Rs.MoveNext

If Rs.EOF Then
    Rs.MovePrevious
    Exit Sub
Else
    For i = 0 To 3
        Text1(i) = Rs.Fields(i)
    Next
End If
End Sub


Private Sub Cmd_last_Click()
If Rs.EOF <> True Then
    Rs.MoveLast
    For i = 0 To 3
        Text1(i) = Rs.Fields(i)
    Next
End If
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值