View Single Post
Old 05-25-2006, 06:09 AM   #4 (permalink)
Andreas Raht
Administrator
 
Andreas Raht's Avatar
 
Join Date: Jun 2002
Location: Hollern/Stade/Germany
Posts: 6,720
Thanks: 200
Thanked 1,393x in 513 posts
Quote:
Originally Posted by dim13
How do you get the ms_access dump into Access ? How do you run the scripts in Access ?

Thanks.
Marc will post the tools that are currently in development on the OOTP2006 site... but until then feel free to use this simple script. Just create an empty Access database, create a Modul and insert the code. Start it with F8 or F5. Or create a form, with a button, with the code "behind it".

ATTENTION!!!! No support for this script, and use at your own risk


Code:
Sub import()
Dim fso As FileSystemObject
Dim fo As Folder
Dim f As File
Dim t As TextStream
Dim z As String
Dim i As Long
Dim db As Database
On Error GoTo err_sub
Set db = CurrentDb()
Set fso = New FileSystemObject
Set fo = fso.GetFolder("C:\ootp\data\saved_games\New Game.lg\import_export")
For Each f In fo.Files
    If f.Name Like "*.access.sql" Then
        
        Debug.Print
        Debug.Print f.Name
        DoEvents
        
        Set t = f.OpenAsTextStream(1)
        i = 0
        Do While Not t.AtEndOfStream
            i = i + 1
            z = t.ReadLine
            z = Trim$(z)
            If z <> "" Then
                db.Execute z, dbFailOnError
            End If
        Loop
        t.Close
        Set t = Nothing
        
    End If
Next f
MsgBox "Done!"
exit_sub:
    On Error Resume Next
    db.Close
    Exit Sub
    
err_sub:
    Debug.Print
    Debug.Print Err.Description
    If z Like "DROP TABLE*" Then
        Resume Next
    Else
        If MsgBox("" & f.Name & vbCrLf & t.Line & vbCrLf & z, vbOKCancel, "Error") = vbOK Then
            Resume Next
        Else
            Resume exit_sub
        End If
    End If
    
End Sub
Andreas Raht is offline   Reply With Quote