I have a function that will append data to a table. The weird thing is that when I run the function it'll produce the following error:
Cannot remove table because it is in use.
When I run it the second time, it works just fine. I cannot seem to find the culprit.
The function is being called from a button on a form that is attached to a generic company.dbf table.
FUNCTION QueryStatus AS C (Starting AS D, Ending AS D )
Queryfrom_queryticks = datetoticks(dtoc(Starting)+" 12:00 AM")
Queryto_Queryticks = datetoticks(dtoc(Ending)+" 11:59 PM")
dim connectionString as c
connectionString = "::Name::Soapware"
delete options
dim options as p
options.ConsolidateArguments= .t.
options.AddTablesToDatabase= .t.
options.ShowProgress= .t.
options.AllowCancel= .t.
delete a_import
dim a_import[0] as p
a_import[].ObjectName = "soapware_scheduling_status_changes"
a_import[..].SQLSelectStatement = "SELECT * from soapware_scheduling_status_changes where (datetime >= '"+var->Queryfrom_Queryticks+"') AND (datetime <= '"+var->Queryto_Queryticks+"')"
a_import[..].SQLType = "Portable"
a_import[..].Arguments = ""
a_import[..].ImportType = "Append to existing table"
a_import[..].AppendOption = "Append unique, replace existing"
a_import[..].AppendToTableName = a5.get_path() + chr(92) + "soapware_scheduling_status_changes"+".dbf"
a_import[..].AppendFieldMap = <<%txt%
Id|Id
Visitid|Visitid
Statusid|Statusid
Datetime|Datetime
%txt%
a_import[..].MasterTableKey = "alltrim(str(Id))+\"_\"+Visitid"
a_import[..].TransactionTableKey = "alltrim(str(Id))+\"_\"+Visitid"
dim flagSilent as l
delete args
dim args as sql::arguments
flagSilent = .t.
delete p
dim p as p
p = a5_AlphaDAO_Import(connectionString,a_import,options,flagSilent,args)
'p has an .hasError and .errorText property
'a_import[] has the following properties for each item: .countRecordsImported, .hasError, .errorText, .userCancelled
QueryStatus = p.hasError
end function
Cannot remove table because it is in use.
When I run it the second time, it works just fine. I cannot seem to find the culprit.
The function is being called from a button on a form that is attached to a generic company.dbf table.
FUNCTION QueryStatus AS C (Starting AS D, Ending AS D )
Queryfrom_queryticks = datetoticks(dtoc(Starting)+" 12:00 AM")
Queryto_Queryticks = datetoticks(dtoc(Ending)+" 11:59 PM")
dim connectionString as c
connectionString = "::Name::Soapware"
delete options
dim options as p
options.ConsolidateArguments= .t.
options.AddTablesToDatabase= .t.
options.ShowProgress= .t.
options.AllowCancel= .t.
delete a_import
dim a_import[0] as p
a_import[].ObjectName = "soapware_scheduling_status_changes"
a_import[..].SQLSelectStatement = "SELECT * from soapware_scheduling_status_changes where (datetime >= '"+var->Queryfrom_Queryticks+"') AND (datetime <= '"+var->Queryto_Queryticks+"')"
a_import[..].SQLType = "Portable"
a_import[..].Arguments = ""
a_import[..].ImportType = "Append to existing table"
a_import[..].AppendOption = "Append unique, replace existing"
a_import[..].AppendToTableName = a5.get_path() + chr(92) + "soapware_scheduling_status_changes"+".dbf"
a_import[..].AppendFieldMap = <<%txt%
Id|Id
Visitid|Visitid
Statusid|Statusid
Datetime|Datetime
%txt%
a_import[..].MasterTableKey = "alltrim(str(Id))+\"_\"+Visitid"
a_import[..].TransactionTableKey = "alltrim(str(Id))+\"_\"+Visitid"
dim flagSilent as l
delete args
dim args as sql::arguments
flagSilent = .t.
delete p
dim p as p
p = a5_AlphaDAO_Import(connectionString,a_import,options,flagSilent,args)
'p has an .hasError and .errorText property
'a_import[] has the following properties for each item: .countRecordsImported, .hasError, .errorText, .userCancelled
QueryStatus = p.hasError
end function