VB連接Access2000,SQL server2000


 

Private Sub Form_Load()
    Dim strConn As String
    Dim pubConn As New ADODB.Connection
    Dim rsTable As New ADODB.Recordset
    Dim strSQL As String

    'Access 2000的連接
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "/North.mdb;Persist Security Info=False"
    'SQL Server2000的連接
    strConn = "Provider=SQLOLEDB.1;Persist Security Info=true;Initial Catalog=DataBaseName;User ID=develop; password=12345;Data Source=HostIP"        
    pubConn.Open strConn

    rsTable.CursorLocation = adUseClient
    strSQL = "select  * from TableName"
    rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
    Set DataGrid1.DataSource = rsTable

End Sub


你可能感兴趣的:(sql,server,datagrid,Security,Access,vb)