boopalank
asked on
How to create a MS Access Database from Visual Basic 6.0
I am developing a small package using VB 6.0 and MSAccess 2000 Database. In that application, I am using two databases. One database, I am always refreshing the data (deleting) whenever I transfer the data but the database file size is keep on bulging (increasing the size). I would like to know how to OPTIMIZE that database from VB. (Note: In MSAccess there is a option to optimize the database but I wanted to do through VB). It is possible for me to advise me on this.
Another request is how to create a MS Access Database from the Visual Basic Application. My requirement is whenever the application is launched the database has to be created and when the applications shuts down that database has to be deleted. Please advise for the these two queries.
Thanks, Boopalan K.
Another request is how to create a MS Access Database from the Visual Basic Application. My requirement is whenever the application is launched the database has to be created and when the applications shuts down that database has to be deleted. Please advise for the these two queries.
Thanks, Boopalan K.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
' add a reference to dao 3.x to your project, if not already done
Compact:
Sub DoCompact(sPath As String, sFilename as string)
On Error GoTo errH
DBEngine.CompactDatabase sPath & "\" & sFilename, "c:\tmp\db.mdb"
Kill sPath & "\" & sFilename
Name "c:\tmp\db.mdb" As sPath & "\" sFilename
Exit Sub
errH:
MsgBox "Error: Database was not compacted.", vbCritical
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
boopalank,
Obviously a number of ways exist. Here is a link that shows you how to create a new Access database and define the tables in XML to allow you to easily reuse the code again in the future.
http://www.vbip.com/xml/XML2Access/XML2Access-01.asp
Dang123
Obviously a number of ways exist. Here is a link that shows you how to create a new Access database and define the tables in XML to allow you to easily reuse the code again in the future.
http://www.vbip.com/xml/XML2Access/XML2Access-01.asp
Dang123
Moderator, my recommended disposition is:
Split points between: twili and Dhaest and EDDYKT
Dan Rollins -- EE database cleanup volunteer
Split points between: twili and Dhaest and EDDYKT
Dan Rollins -- EE database cleanup volunteer
as a trick, in order to create a new DB, you could have a real clear DB file as a temporary element that you use to make a copy where you need, use the copy, and then dispose it (always keeping the "template" like empy DB).
This is just an idea. I did once create a DB, but forgot it. I'll try to look for it and let you know.
For the optimization no idea for now.
Bye,
Max