A break on CODING have a rest and respect

From the time before you were born and you are inside the womb of your mother we don’t know on what are the sacrifice that she did for us to live all we know is that we are inside the womb and for a specific time of period were alive.
At first it’s all dark and there is no assurance if you will live or not but there is one person who gave you the strength to live. Foods and sacrifices are the reasons why you are alive inside the womb of your mother until such time that you were born and your mother hears your first cry. All she can offer after giving birth is her smile, an assurance that you are alive and finally she can consider herself… a MOTHER.   
                Mother, Mama, ,Mommy Mom etc., that’s what we call to a person who gave us this life, but sometimes we overdo it and forget the importance of having our mother. I’m lucky enough that my mother is the one who build my path ahead from the future, from getting my bachelors degree and on having my first Job related to my degree. She’s always there and giving the Guidance that I need. She supported my decisions and give guidance in order for me to get the right decision in life. She serves as Light from the dark, until now even though she’s not here and she’s on the place that there’s no problem, hatred and negative thoughts she will always be my foundation in LIFE. She’s the one who made me responsible enough. Now that she’s not here all I can say is that:
                Thank You Mama you are my strength. Guide and provide me the light that I Need for I know that “You are the LIGHT and the FIRST LOVE of my LIFE.” Ma, remember the last words that I told you before you go, “Ma basta tandaanam ay-ayatin daka!”.
 
 

Backup and Restore Database using VB6


One issue on creating a system is the database, when your database goes down and it crushes what are the solutions that your system might do, this would be the basis of measuring the reliability of a system, when a database goes down is there any way to recover its content partially, or is there any way to make a copy of the database on a separate drive of location on your computer?
There are solutions that we may do first is to create a function on our system to create a copy of the database or also we call this as backup and when the database crushes you may restore its database, take note that if you will restore a database you cannot restore all of the content from the original one because the records that we may restore are the data which had been saved at the moment that we backup our database.

This feature is a matter of Copying a File to another Location
Let me define first some codes before we start
FileCopy Source,Destination
Source where is our database located usually on our default folder, and destination is where we want to put our Backup, Note that FileCopy is a built in function on vb6 that enable you to copy a file
App.path
                Gets the specific  Location of our project
New controls to be used
                CommonDialog-  can be used to browse for a specific location it’s like the save as and open on Microsoft Word

Now let’s do some design
1.       Just create a Form Containing two button first button would have a caption “Backup” and the second Button is “Restore”
2.       Add some components press ctrl+t then check this component 
3.       Then add this control on your Form located on the Tool box


Now let’s do the coding
                I let the name of the controls to its default name, on button backup put this line of codes
1.       Me.CommonDialog1.Filter = "*.mdb"
This line code just declare that you can only save the file as .mdb
2.       Me.CommonDialog1.ShowSave
IT shows the dialog box to located where do you want to save the file and what would be the name of the file to be backup
3.       If Me.CommonDialog1.FileName <> "" Then
Checks whether open button is clicked
4.       FileCopy App.Path & "\\Data\\db_SADStore.mdb", Me.CommonDialog1.FileName & ".mdb"
A code to copy the file on another location the source is on the data folder on my project meaning the structure of my  project is Default Folder>> Data>> db_SADStore.mdb
5.       MsgBox "Database had been successfully Saved on " & Me.CommonDialog1.FileName & ".mdb"
It just inform the user that the file is saved on  that specific location
6.       End if
End of the code

                Take note that if you are dealing with  an error Access Denied there are some reasons first is to close your  ms access file it might be open, second is you need to close the connection on your code you might want to close it use the ConnectionName.Close then open it after doing a backup and lastly you must run your vb6 as administrator.

                Now Backup is done it’s up for you to do the restore function it’s just the reverse On FileCopy just make the destination be the source and the Source would be the destination. But take note remove the “.mdb” on the destination on backup and change Me.CommonDialog1.ShowSave to Me.CommonDialog1.ShowOpen
Think Logically hahah. J

Main form
Dialog appears when Backup button is clicked

Dialog show the path of the backup file
Happy Coding