用DAO建库,其他的用SQL语句吧!
解决方案 »
- 请问,如何触发ComboBox的chang事件?
- VB 请教高手关于用户控件问题
- 怎么样在unload事件里取消 Unload
- 目的是不断的从a数据表逐行写入b数据表,希望首先查询b数据表的数据纪录(id),然后再从对应的a数据表传输数据,发现只能传一行数据,下
- 一个关于可视化数据管理器使用的问题
- VB连接ACCESS问题!
- 如何获取最新文件列表信息
- 进销存软件中发出成本计算在何时进行,以这4种计价方式为例,详见内。
- 如何双击表格任一行的任一处就可以将整行选中并弹出另外一个窗口?
- 请问大家,如何编程实现清空IE历史记录,但又可以保留特定的记录?
- 请教高手,请教高手,请教高手
- treeview里怎樣刪除一個子節點,急用..在線等候
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
在程序中创建数据库的方法不仅速度慢,而且复杂。如果需要经常生成新库,做个数据库模板文件,直接拷贝文件生成新库比较好。
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