How to create .mdb or .accdb files?
-
I'm working with Qt Creator 4.14.2. My application is based on MSVC2019, 32 bit.
I need help creating an mdb or accdb file during runtime of an application. I found two threads on this forum- https://forum.qt.io/topic/3990/how-to-create-a-ms-access-mdb-file-by-qt
- https://forum.qt.io/topic/58929/how-to-create-a-new-xx-mdb-ms-access-file-file-using-qt
I deduced that it is not easier to create Access files in runtime or not possible to create. Is it still like that? Above threads dated back to 2011 and 2015.
I have used QFile which is only creating a text file with accdb extension.
Some external posts say that as soon as db.open() is called, Qt creates the file automatically. It is not happening in my case. Am I missing anything in my Qt installation? What should be installed via Qt Maintenance tool if I want file to be created automatically?
Regards
-
@VRonin
Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
And also can I have multiple db connections open during runtime?@manikanta27 said in How to create .mdb or .accdb files?:
Can you help me with a sample code to copy a file to some other location
See https://doc.qt.io/qt-5/qfile.html#copy-1
Yes, you can have more than one connection to a db at runtime. See https://doc.qt.io/qt-5/qsqldatabase.html, you can give each connection its own name. -
The Qt ODBC driver has no problem managing ms access files but it can't create them out of the box. What you could do is use MS Access to create a blank database and then add that to the resources of your program. When you need to create a new DB, then, you would just copy that stored file.
-
@VRonin
Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
And also can I have multiple db connections open during runtime? -
@VRonin
Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
And also can I have multiple db connections open during runtime?@manikanta27 said in How to create .mdb or .accdb files?:
Can you help me with a sample code to copy a file to some other location
See https://doc.qt.io/qt-5/qfile.html#copy-1
Yes, you can have more than one connection to a db at runtime. See https://doc.qt.io/qt-5/qsqldatabase.html, you can give each connection its own name.