I'm using the ODBC Text Driver(Microsoft Text Driver) in order to read a TXT file and import the data from that file into a database. The file is pretty big, therefore the query takes long time to run. Because of that, and because I want the user to be able to cancel the process any time , I try to execute asynchronously this operation.
I have a system DSN created for this driver, and I'm using the following code:
Set ws = CreateWorkspace("ws", "admin", "", dbUseODBC)
sConn = "ODBC;DSN=userText;UID=;PWD=;"
Set cn = ws.OpenConnection("", dbDriverNoPrompt, False, sConn)
sSQL = "SELECT * INTO [test] IN '" & App.Path & "\TempDB.mdb" & "' FROM myData.txt"
Set qry = cn.CreateQueryDef("", sSQL)
'Execute asynchronously
qry.Execute dbRunAsync
If qry.StillExecuting Then
if blnCancel then qry.Cancel
end if
qry.Close
cn.Close
The problem is that when the query begins to execute the SQL statement, even is mentioned to be asynchronously, the VB application waits till the process is done. When I get to the line to check the StillExecuting prop, this one is always False.
What is wrong in my program and how can I make it work.
Any help will be appreciated.
Thanks!
I have a system DSN created for this driver, and I'm using the following code:
Set ws = CreateWorkspace("ws", "admin", "", dbUseODBC)
sConn = "ODBC;DSN=userText;UID=;PWD=;"
Set cn = ws.OpenConnection("", dbDriverNoPrompt, False, sConn)
sSQL = "SELECT * INTO [test] IN '" & App.Path & "\TempDB.mdb" & "' FROM myData.txt"
Set qry = cn.CreateQueryDef("", sSQL)
'Execute asynchronously
qry.Execute dbRunAsync
If qry.StillExecuting Then
if blnCancel then qry.Cancel
end if
qry.Close
cn.Close
The problem is that when the query begins to execute the SQL statement, even is mentioned to be asynchronously, the VB application waits till the process is done. When I get to the line to check the StillExecuting prop, this one is always False.
What is wrong in my program and how can I make it work.
Any help will be appreciated.
Thanks!