VB连接oracle9I数据库

Option Explicit
Public appdisk As String
Public conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public db As String
Private sSQL As String

Private Sub Command1_Click()
   
    If Trim(Text1.Text) = "" Then
        MsgBox "must input", vbCritical, "error"
        Text1.SetFocus
        Exit Sub
    End If
   
    If Trim(Text2.Text) = "" Then
        MsgBox "must input", vbCritical, "error"
        Text2.SetFocus
        Exit Sub
    End If

    sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "'"
    Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
    If Rs.EOF = True Then
        MsgBox "no this user", vbCritical, "error"
        Text1.SetFocus
        Rs.Close: Set Rs = Nothing
        Exit Sub
    End If

    Rs.Close: Set Rs = Nothing
   
    sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "' and password='" & Trim(Text2.Text) & "'"
    Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
    If Rs.EOF = True Then
        MsgBox "password is wrong", vbCritical, "error"
        Text2.SetFocus
        Rs.Close: Set Rs = Nothing
        Exit Sub
    Else
        If Val(Rs!Levels) = 0 Then
            Form2.Show 1
        Else
            Form3.Show 1
        End If
    End If

    Rs.Close: Set Rs = Nothing
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Form_Load()
    Dim i As Integer
   
    On Error GoTo Err
   
    appdisk = Trim(App.Path)
    If Right(appdisk, 1) <> "/" Then appdisk = appdisk & "/"
    db = appdisk
    db = "Provider=MSDAORA.1;Password=chun;User ID=chun;Data Source=chun;Persist Security Info=True"
    conn.CursorLocation = adUseClient
    conn.Open db
    Exit Sub
   
Err:
    MsgBox Err.Number
    Unload Me

End Sub

'自己建立from吧  from1的代码就是这些  我得库名是CHUN 你给改成自己的就可以了  就下面这句话

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值