none
如何设置对VB数据库连接的动态路径 RRS feed

  • 常规讨论

  • On Error Resume Next
    If DataEnvironment1.rsCommand1.State <> adStateClosed Then
    DataEnvironment1.rsCommand1.Close 注释:如果打开,则关闭
    End If
    注释:i = InputBox("请输入友人编号:", "输入")
    注释:If i = "" Then Exit Sub
    DataEnvironment1.Connection1.Open App.Path & "\userdatabase\tsl.mdb"
    DataEnvironment1.rsCommand1.Open "select * from table3 where 编号=注释:" & i & "注释:"
    注释:Set DataReport2.DataSource = DataEnvironment1
    注释:DataReport2.DataMember = "command1"
    注释:DataReport2.show
    end sub

    四、利用ADO(ActiveX Data Objects)进行编程:
    建立连接:
    dim conn as new adodb.connection
    dim rs as new adodb.recordset
    dim str
    str = App.Path
    If Right(str, 1) <> "\" Then
    str = str + "\"
    End If
    str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & "\tsl.mdb"
    conn.open str
    rs.cursorlocation=aduseclient
    rs.open "数据表名",conn,adopenkeyset.adlockpessimistic
    用完之后关闭数据库:
    conn.close
    set conn=nothing
    2009年5月27日 8:42