1 引用dao3.6
2 DAO使用database对象和recordset对象:
dim db as database, rs as recordset
set db = dbengine.opendatabase("数据库文件路径名称")
set rs = db.openrecordset("表名或SQL语句")
2 DAO使用database对象和recordset对象:
dim db as database, rs as recordset
set db = dbengine.opendatabase("数据库文件路径名称")
set rs = db.openrecordset("表名或SQL语句")
一定是你的打开语句有问题。
把你的代码贴上来。不要让我们猜。
Private Sub Form_Load()
DiskPathName = App.Path
If Right(DiskPathName, 1) = "\" Then
DiskPathName = Left(DiskPathName, Len(DiskPathName) - 1)
End If
With Data1
.Connect = "access2000;uid=;pwd=123"
.DatabaseName = DiskPathName + "\sbjl.mdb"
.RecordSource = "bf"
.Refresh
.Recordset.MoveLast
End With
我知道用ADO可以打开:
cnTest.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123;" + " Data Source =" + DiskPathName + "\sbjl.mdb"
cnTest.Open ConnectionString
可是我用ADO以后所有原来的程序都要改,我闲麻烦!请高手们指点为什么用DAO打不开!还是提示找不到可插入的ISAM
我的库中只有表格和查询(有图片字段)
先定义ODBC
再:dim cn as new adodb.connection
dim rs as adodb.recordset
dim constring as stringconstring="provider=msdasql;dsn=dsn;uid=uid;pwd=pwd"
cn.CursorLocation = adUseClientset rs=new adodb.recordsetcn.open constring
rs.open "select * from table where ***"
.Connect = ";uid=;pwd=123"
使用JET4.0以上
Dim DR As RecordsetSet MyDB = DBEngine.OpenDatabase("c:\test.mdb", False, False, ";Pwd=1234")
Set DR = MyDB.OpenRecordset("Select * From Table")
Intrinsic Data Control Is Usable with Access 2000 DatabasesAt design time, trying to bind the Data control to a Microsoft Access 2000 database will result in an error: "Unrecognized database format." The Data control can still be used, however, by following the example below: 1、On the Project menu, click References. Clear the Microsoft DAO 3.51 Object Library check box.
2、Set a reference to the Microsoft DAO 3.6 Object Library.
3、Draw a Data control and a TextBox control on a form.
4、On the Properties window, set the TextBox control's DataSource property to the Data control.
5、Type the name of the field CompanyName into the DataField property box.
6、Insert code similar to the following into the code window: Option Explicit
Private daoDB36 As Database
Private rs As Recordset
Dim sPath As StringPrivate Sub Form_Load()
sPath = _
"C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
Set daoDB36 = DBEngine.OpenDatabase(sPath)
Set rs = daoDB36.OpenRecordset("Customers")
Set Data1.Recordset = rs
End Sub7、Run the project.