用DAO建库,其他的用SQL语句吧!

解决方案 »

  1.   

    Sub CreateDatabaseX()   Dim wrkDefault As Workspace
       Dim dbsNew As DATABASE
       Dim prpLoop As Property   ' Get default Workspace.
       Set wrkDefault = DBEngine.Workspaces(0)   ' Make sure there isn't already a file with the name of 
       ' the new database.
       If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"   ' Create a new encrypted database with the specified 
       ' collating order.
       Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
          dbLangGeneral, dbEncrypt)   With dbsNew
          Debug.Print "Properties of " & .Name
          ' Enumerate the Properties collection of the new 
          ' Database object.
          For Each prpLoop In .Properties
             If prpLoop <> "" Then Debug.Print "  " & _
                prpLoop.Name & " = " & prpLoop
          Next prpLoop
       End With   dbsNew.CloseEnd Sub
      

  2.   

    做一个空的mdb文件,需要建库的时候使用filecopy函数拷贝就可以了
      

  3.   

    在www.epoint.com.cn/controls上面有原代码。
      

  4.   

    同意Mailbomb(网络咖啡) 
    在程序中创建数据库的方法不仅速度慢,而且复杂。如果需要经常生成新库,做个数据库模板文件,直接拷贝文件生成新库比较好。
      

  5.   

    access2000  + vb:ADOdim cn as new connection  '建立库连接
    dim rs as new recordset   
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\123.mdb;Jet OLEDB:Database Password=123;Persist Security Info=False"
    rs.Open "select (这里填你想要查找的字段) from (这里填你的表名)", cn, adOpenStatic, adLockOptimistic对库的操作:
    rs.delete '删除记录
    如:
    rs.Find "用户名='" & txtusername.Text & "'"
    rs.Delete
    rs.updata
    rs.addnew '添加记录
    如:
    rs.Fields("用户名") = txtusername.Textrs.updata '刷新记录
    操作完毕记得关闭并释放对象
    rs.close
    cn.close
    Set rs=Nothing
    Set cn=Nothing