open mdb file
-
As RageInTheMachine9532 said, a code sample would help us help you. Right now we don't have enough information.
-
As RageInTheMachine9532 said, a code sample would help us help you. Right now we don't have enough information.
-
set db as database set rec as recordset open db=opendatabase("xx.mdb") open rec=db.openrecordset("select * from xx",opendynaset) I GOT ERROR AT LINE NUMBER 3
Well the syntax of your example is not correct but I think I know what you're trying to do. The first thing that I'd do is try using the absolute path of the database and see if that works. Here is an example of the same code that I tried that worked.
Dim db As Database Dim rs As Recordset ' open the database in the application directory Set db = OpenDatabase(App.Path & "\mydata.mdb") Set rs = db.OpenRecordset("SELECT * FROM MYTABLE")
The only other thing that I'd recommend is that you use ADO vs. DAO. -
Well the syntax of your example is not correct but I think I know what you're trying to do. The first thing that I'd do is try using the absolute path of the database and see if that works. Here is an example of the same code that I tried that worked.
Dim db As Database Dim rs As Recordset ' open the database in the application directory Set db = OpenDatabase(App.Path & "\mydata.mdb") Set rs = db.OpenRecordset("SELECT * FROM MYTABLE")
The only other thing that I'd recommend is that you use ADO vs. DAO. -
i tried to do it but i get the same massege any connection to the projet refrenses, i choose(microsoft dao 3.6)?
Then you might want to try hard coding the entire path to the database in your OpenDatabase statement because it looks like OpenDatabase can't find your filename in the default path or the path your project is running from.
Dim db As Database
Dim rs As Recordset' open the database from exactly where I say it is
Set db = OpenDatabase("C:\FullPath\ToMyDatabase\mydata.mdb")
Set rs = db.OpenRecordset("SELECT * FROM MYTABLE")and SERIOUSLY consider moving your code to ADO instead of DAO. DAO seems to be a dead technology. If your using VB6, you can start here[^] to learn about ADO. If your using VB.NET, you might want to start here[^]. RageInTheMachine9532
-
i tried to do it but i get the same massege any connection to the projet refrenses, i choose(microsoft dao 3.6)?
In Project References try using: "Microsoft ActiveX Database Object 2.7 Library." If you don't have the 2.7 library, you should have either 2.0, 2.1, 2.5, or 2.6. Use one of them. I was looking in the VB documentation and for DAO it says that the OpenDatabase statement is depricated and that you should use the DBEngine object to open a database. So if you must use DAO, then try checking out the documentation on the DBEngine object. By the way, I was able to use DAO to access my database. So maybe you have some other configuration problem.
-
In Project References try using: "Microsoft ActiveX Database Object 2.7 Library." If you don't have the 2.7 library, you should have either 2.0, 2.1, 2.5, or 2.6. Use one of them. I was looking in the VB documentation and for DAO it says that the OpenDatabase statement is depricated and that you should use the DBEngine object to open a database. So if you must use DAO, then try checking out the documentation on the DBEngine object. By the way, I was able to use DAO to access my database. So maybe you have some other configuration problem.
-
I am using access 2003. is there any special configuration for this version that you know about that i should try?
Are you getting an error number? I tried to open a file that didn't exist and I got a run time erro #3024. Is that what you get? Or do you get some other number error number? Regarding Access 2003, I'm not aware of any configuration stuff that would affect a VB program.
-
Are you getting an error number? I tried to open a file that didn't exist and I got a run time erro #3024. Is that what you get? Or do you get some other number error number? Regarding Access 2003, I'm not aware of any configuration stuff that would affect a VB program.
-
I'm grasping at straws...but have you tried opening up another database file. Maybe create a database with one table and try to access that. OR Maybe it's a sharing violation. In the past I've had trouble opening a database if I had it open in MS-Access, especially if it's open exclusively by MS-Access.