Office中國(guó)論壇/Access中國(guó)論壇

 找回密碼
 注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

在服務(wù)器或客戶端用ADO復(fù)制一個(gè)表

1970-1-1 08:00| 發(fā)布者: 竹笛| 查看: 3568| 評(píng)論: 1

一、從服務(wù)器創(chuàng)建到客戶端:
Public Sub Main3()
'當(dāng)創(chuàng)建成功后,如果要再次創(chuàng)建,請(qǐng)刪除已創(chuàng)建的表,否則提示出錯(cuò)
    Dim Cnxn As ADODB.Connection
    Dim Cnxn_source As ADODB.Connection
    Dim rstTitles As ADODB.Recordset
    Dim strSQLRestore As String
    Dim strCnxn_source As String
    Dim strSQLTitles
    Dim strCnxn As String
    '數(shù)據(jù)庫(kù)設(shè)有密碼:123456
    strCnxn_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & CurrentProject.Path & "\ado001_be.mdb" & ";jet oledb:database password=123456"
    '數(shù)據(jù)為密碼為空
    ' strCnxn_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & CurrentProject.Path & "\ado001_be.mdb"
    Set Cnxn_source = New ADODB.Connection
    Cnxn_source.Open strCnxn_source
   
   
    strSQLRestore = "SELECT * INTO tblUser_make FROM [MS Access;DATABASE=" & CurrentProject.Path & "\ado001_be.mdb;UID=admin;PWD=123456].[tblUser]"
    '  strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & CurrentProject.Path & "\ado001.mdb"
        strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & CurrentProject.Path & "\ado001.mdb;"
    Set Cnxn = New ADODB.Connection
    Cnxn.Open strCnxn
    Set rstTitles = New ADODB.Recordset
    Cnxn.Execute strSQLRestore, , adExecuteNoRecords
    Cnxn.Close
    Set rstTitles = Nothing
    Set Cnxn = Nothing
    MsgBox "已成功執(zhí)行此操作"
    Exit Sub
End Sub




別人笑我太瘋

發(fā)表評(píng)論

最新評(píng)論

引用 topses 2009-12-9 22:45
這代碼寫得太亂了,內(nèi)容都最基本的,不如幫助文件 的一半好 最重要的是標(biāo)題也不對(duì),容易誤導(dǎo)別人“在服務(wù)器或客戶端用ADO復(fù)制一個(gè)表” SELECT * INTO 只能復(fù)制表的數(shù)據(jù)及數(shù)據(jù)類型,索引,KEY等均不會(huì) SELECT * INTO 創(chuàng)建新表時(shí),新表中的字段將繼承查詢基本表中每一個(gè)字段的數(shù)據(jù)類型及大小,但不傳遞其他的字段或表屬性。

查看全部評(píng)論(1)

QQ|站長(zhǎng)郵箱|小黑屋|手機(jī)版|Office中國(guó)/Access中國(guó) ( 粵ICP備10043721號(hào)-1 )  

GMT+8, 2025-7-17 00:43 , Processed in 0.068738 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回頂部