Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when using asynchronous process

Status
Not open for further replies.

Lumi

Programmer
Sep 19, 2002
1
US
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top