Free for PREMIUM members
[Webinar] Streamline your web hosting managementRegister Today
Public Function ReadSql()
Dim dbs As Database
Dim qdf As QueryDef
Dim intFileDesc As Integer 'File descriptor for output file
Dim strSourceFile As String 'Full path of source file
Dim strTextLine As String 'Input buffer
Dim strSQL As String
Set dbs = CurrentDb
strSourceFile = "c:\test\test.sql"
intFileDesc = FreeFile
Open strSourceFile For Input As #intFileDesc
Do While Not EOF(intFileDesc) ' Loop until end of file.
Line Input #intFileDesc, strTextLine 'Read line into buffer
strSQL = strSQL & strTextLine & vbCrLf
Close #intFileDesc 'Close file.
On Error Resume Next
Set qdf = dbs.QueryDefs("tmpQdf")
If Err.Number <> 0 Then
Set qdf = dbs.CreateQueryDef("tmpQdf")
qdf.Sql = strSQL
Set qdf = Nothing
Set dbs = Nothing 'Garbage handling before we exit the function
Open in new window
The revolutionary project management tool is here! Plan visually with a single glance and make sure your projects get done.
(I assume that is what the sql file is for).
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $159.20.
Premium members get this course for $79.20.
Premium members get this course for $174.99.
Premium members get this course for $389.00.
Premium members get this course for $62.50.
Premium members get this course for $122.40.