使用ADO。
谢谢!

解决方案 »

  1.   

    '20分,真扣门。
    Public Function CreateDB() As Boolean
        Dim rst As New Recordset
        
        '无数据库连接
        myCnn.ConnectToServer False
        '建库
        strSql = "select name from sysdatabases where name='deptlists'"
        rst.Open strSql, myCnn.Cnn, 3, 3
        If rst.RecordCount > 0 Then
            strSql = "drop database deptlists"
            myCnn.Cnn.Execute strSql
        End If
        rst.Close
        strSql = "create database DeptLists on (name='deptlist_m',filename=" & _
                "'e:\第二学期\deptlist.mdf',size=1) log on (name='deptlist_l'," _
                & "filename='e:\第二学期\deptlist.ldf',size=1)"
        myCnn.Cnn.Execute strSql
        '有库连接
        myCnn.ConnectToServer
        '建表
        strSql = "create table Deptl (lngDeptID int primary key," _
                & "lngFatherID int,StrDeptName varchar(20))"
        myCnn.Cnn.Execute strSql
        '插入记录
        strSql = "insert into deptl select 1,0,'北京部' union" & _
                    " select 2,0,'上海部' union select 3, 0,'广州部' union" & _
                    " select 4,1,'海淀分部' union select 5,1,'朝阳分部' union" & _
                    " select 6,1,'西城分部' union select 7,2,'静安分部' union" & _
                    " select 8,2,'黄埔分部' union select 9,4,'知青路分部' union" & _
                    " select 10,4,'北外门分部'"
        myCnn.Cnn.Execute strSql
        '建表2
        strSql = "create table RandNumAver(Num numeric)"
        myCnn.Cnn.Execute strSql
        '建存储过程
        strSql = "create proc getdeptid as declare @newid int" & vbCrLf & _
                "select @newid=max(lngdeptid) from deptl" & vbCrLf & _
                "set @newid=@newid+1" & vbCrLf & "return @newid"
        myCnn.Cnn.Execute strSql
        Set rst = Nothing
        CreateDB = True
        Exit Function
    ErrCreateDB:
        MsgBox "数据库初始化失败!!!" & vbCrLf & Err.Description, _
                vbCritical, "错误信息"
    End Function
      

  2.   

    加30分比如,怎样创建一个Access数据库(*.mdb)文件?
      

  3.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=195890
      

  4.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=179417
      

  5.   

    Conn.execute "Create DataBase XXXX"
      

  6.   

    创建MDB数据库用DAO比较方便啊
    Public DAOWorkspace As dao.Workspace
    Public DAODataBase As dao.Database   
    Set DAOWorkspace = DBEngine.Workspaces(0)
    Set DAODataBase = DAOWorkspace.CreateDatabase(创建数据库路径, dbLangGeneral)
    记得引用DAO
      

  7.   

    UP~~~~~~~~
    ----------------------
    《CSDN论坛新助手 CSDN's forum Explorer》
    1、更快速的浏览
    2、更方便地保存
    3、更快捷的收/发短信
    下载地址:http://www.seeyou.com.cn/CoolSlob/CSDNExplorer.exe
    更多说明:http://community.csdn.net/Expert/TopicView.asp?id=3255966
      

  8.   

    采用李洪根的方法报错
    “找不到可用的ISAM”
      

  9.   

    参考:
    http://p2p.wrox.com/topic.asp?TOPIC_ID=1017
      

  10.   

    Dim cat As New ADOX.Catalog
    Public Sub newfile()
    CommonDialog1.DialogTitle = "Please enter the new database name"
    CommonDialog1.Filter = "Access database file MDB|*.mdb"
    CommonDialog1.FileName = ""
    CommonDialog1.InitDir = App.Path
    CommonDialog1.ShowSave
    dataname = CommonDialog1.FileName
    If dataname = "" Then
        Exit Sub
    Else
        cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataname   
       
    End If
    End Sub使用ADO+datagrid.引用ADOX 2.6