vb和access的问题
如何用vb解决以下问题:
1、如何用vb建立一个mdb数据库文件(3分)
2、在建立好的数据库中用代码建立数据库对象(表格,视图)
3、如何用vb代码为access数据库添加用户和组(5分)
4、如何用vb代码设置用户与组的权限(5分)
[解决办法]
好像这几个都可用adox搞定,在论坛中搜索一下吧
Library ADOX
C:\Program Files\Common Files\System\ado\msadox.dll
Microsoft ADO Ext. 2.8 for DDL and Security
http://so.csdn.net/bbsSearchResult.aspx?q=adox&category=all&uname=&rname=&d1=2008-01-01&d2=2010-03-09&field=all
[解决办法]
'---------------------------------------------------' 过程名 : CreateMdb' 时间 : 2010-3-9 22:22' 作者 : 杨过.网狐.cn' 功能 :' 说明 :'---------------------------------------------------'Public Sub CreateMdb() On Error GoTo CreateMdb_Error '创建mdb Dim cat As New ADOX.Catalog, strMdbFile As String strMdbFile = App.Path & "\test.mdb" cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strMdbFile On Error GoTo 0 Exit SubCreateMdb_Error: MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure CreateMdb of Form Form1"End Sub'---------------------------------------------------' 过程名 : CreateTable' 时间 : 2010-3-9 22:30' 作者 : 杨过.网狐.cn' 功能 :' 说明 :'---------------------------------------------------'Public Sub CreateTable() On Error GoTo CreateTable_Error '创建表 Dim str_Connection As String ' Dim str_MdbFile As String ' Dim cnn_Access As ADODB.Connection Dim SQLCreate As String str_MdbFile = App.Path & "\test.mdb" str_Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & str_MdbFile & _ ";Persist Security Info=False" Set cnn_Access = New ADODB.Connection cnn_Access.Open str_Connection SQLCreate = "create table table1 (id char(8) not null, sname char(10))" Call cnn_Access.Execute(SQLCreate, 1, adCmdText) cnn_Access.Close On Error GoTo 0 Exit SubCreateTable_Error: MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure CreateTable of Form frmMdb"End SubPublic Sub CreateIndex() On Error GoTo CreateTable_Error '创建索引 Dim str_Connection As String ' Dim str_MdbFile As String ' Dim cnn_Access As ADODB.Connection Dim SQLCreate As String str_MdbFile = App.Path & "\test.mdb" str_Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & str_MdbFile & _ ";Persist Security Info=False" Set cnn_Access = New ADODB.Connection cnn_Access.Open str_Connection SQLCreate = "create index IdxT1Id on table1 (id )" Call cnn_Access.Execute(SQLCreate, 1, adCmdText) cnn_Access.Close On Error GoTo 0 Exit SubCreateTable_Error: MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure CreateTable of Form frmMdb"End Sub