Auto-Convert Database

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
I was wondering if it was possible to write a code in C# or SQL and have the code cycle through a folder let's say for example C:\Databases\ and take each database in that folder, create a copy of that database, and convert the copy of the database to 2007.
 
Joined
May 20, 2010
Messages
4,040
Answer is Yes... I don't know about C# (I am doing java), but I am sure it can because it supports IO programming. Not sure about the conversation anyway, but that is also possible.
 

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
Language wouldn't matter since I was just thinking about it being a batch file that you click on and it automatically does everything. Can you provide some insight on how to write it via Java?
 

DoubleHelix

Banned
Joined
Dec 9, 2004
Messages
24,388
A batch file is just a series of commands. Do you know the commands for converting the database? What is "2007" (other than a calendar year)?

You have to actually know the commands you need to run to perform an operation.
 

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
Right...I was hoping for some insight on how to write the batch file, regardless of what language was being used. I do not know what the commands would be to perform these actions, but was hoping someone more experienced/advanced does.
 
Joined
May 20, 2010
Messages
4,040
If you can use the newest version of the JAVA, which is JAVA 7, there is a new package called "nio" (new input output). This will package has Classes supporting for this action. There is a static method called "copy()" inside "Files" class which will help you in this case. Here is the link

http://docs.oracle.com/javase/tutorial/essential/io/copy.html


If you can't use this JAVA 7, still it is possible. Use streams, convert the file to a set of bytes and transfer.
 

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
That Java will create a copy of my file :) Perfection part A is done...anyone have any idea's how to automate the process of converting an access 2000 database to an access 2007
 

DoubleHelix

Banned
Joined
Dec 9, 2004
Messages
24,388
The coding language doesn't have anything to do with the commands that actually perform the work. There isn't a command in any language that does "convert my database". It's like you're trying to write a great mystery novel, and your focusing on what Word processing program to use to type it without having established a plot or any characters.

What kind of conversion operation do you need to do?
 
Joined
May 20, 2010
Messages
4,040
The coding language doesn't have anything to do with the commands that actually perform the work. There isn't a command in any language that does "convert my database". It's like you're trying to write a great mystery novel, and your focusing on what Word processing program to use to type it without having established a plot or any characters.

What kind of conversion operation do you need to do?
Agree with DoubleHelix. It is better if you can do that manually. However if you can get the bytes of the current format and covert it to the new format, it will work for sure. It is completely hard programming. But pardon me, I don't know how to do that.
 

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
That's what I was afraid of. There are just over 500 databases, and was trying to automate the process if at all possible.

Helix - I was wanting to first create a copy of an access2000 database, and then convert that copy of the database to access20007.

However, knowing how to copy the databases pro grammatically will save a great deal of time.
 

jo15765

Thread Starter
Joined
Oct 11, 2011
Messages
307
I just found this...do you guys think this would work effectively, and include a search of subfolders: And by subfolders I mean let's say that I want to search my entire C:\ drive and find any .mdb file extension and covert it, would this search strictly in the C:\ folder or would it search the subfolders within my C:\ drive as well?
Code:
Sub ConvertDb(oldDbPath As String, newDbPath As String)

Dim x

Dim strDBName As String
Dim strOLDDB As String
Dim strNewDb As String

strDBName = Dir(oldDbPath & "\*.MDB")   ' Retrieve the first MDB file entry.

'Loop though the files in the folder to find MDB files.

Do While strDBName <> ""
' Ignore the current folder and the encompassing folder.
  If strDBName <> "." And strDBName <> ".." Then
        
    If Right(strDBName, 3) = "mdb" Then
       strOLDDB = oldDbPath & "\" & strDBName
       strNewDb = newDbPath & "\" & strDBName

       Application.ConvertAccessProject _
       SourceFilename:=strOLDDB, _
       DestinationFilename:=strNewDb, _
       DestinationFileFormat:=acFileFormatAccess2007
       'May or may not want messagebox to display when conversion completed
       'MsgBox "Conversion complete."
    End If
  End If
strDBName = Dir    ' Get next MDB.
Loop

End Sub
http://support.microsoft.com/kb/304318
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top