Re: What, in general, is defined as a Close in FoxPro 6? by Dan
Dan
Fri Apr 25 13:08:40 CDT 2008
Oh, it certainly has meaning. It means nobody else can use the data so it
should be done sparingly and usually in conjunction with taking down the web
server (or at the very least the application) for the duration of the task.
Dan
B. Chernick wrote:
> Thanks. I'm beginning to share your opinion. Actually I think they
> should just fire up VFP 6 and do it manually, but this is what they
> demanged, and I didn't have enough FoxPro experience to protest. :-)
>
> By the way, given the disconnected nature of a web app, does a Use
> Exclusive on a dbf file have any real meaning?
>
> "Olaf Doschke" wrote:
>
>>> When dealing with FoxPro 6 dbf tables, what constitutes a 'Close'?
>>> (I realize this is a rather broad question.)
>>
>> USE
>>
>> like others already said in your other thread this is definitely
>> the command for both opening and closing a table.
>>
>> As it's all about PACK and exclusive use of the table,
>> why would you do that via a web app, why not
>> consider doing it with a small VFP6 EXE running on
>> the server, eg as a scheduled task.
>>
>> Use Execscript() as your main NonQuery Command,
>> then you can issue a whole skript, not only single commands.
>>
>> that skript should look like this:
>>
>> LOCAL llSuccess
>> TRY
>> SELECT 0
>> USE sometable in 0 EXCLUSIVE
>> PACK IN sometable
>> USE IN sometable
>> llSuccess = .T.
>> CATCH
>> * something went wrong
>> llSuccess = .F.
>> FINALLY
>> USE IN SELECT('sometable')
>> ENDTRY
>>
>> RETURN llSuccess
>>
>> That will try to pack a table and return if it succeeds as a bool
>> value. You may want to RETURN IIF(llSuccess,1,0) to return 1 for
>> success
>> and 0 for failure instead or simply set llSuccess to 0 and 1 instead
>> of ..F. and .T.
>>
>> Save the skript as a text, read it into a string and pass it on as an
>> OleDBParameter.
>>
>> This could work but is untested. Just to give you the idea:
>>
>> Dim oFile as System.IO.File
>> Dim oRead as System.IO.StreamReader
>> Dim Script as String
>>
>> oRead = oFile.OpenText("D:\vfpscript.txt")
>> Script = oRead.ReadToEnd()
>>
>> Dim dc As New OleDb.OleDbConnection(<same connection string used in
>> the rest of the app>)
>> dc.Open()
>>
>> Dim dcc As New OleDb.OleDbCommand( "Execscript(@Script)",dc)
>> dcc.Paramters.Add(New OleDBParameter("@Script",
>> OleDBType.LongVarChar).Value = Script)
>> If dcc.ExecuteNonQuery() Then
>> ' Could PACK
>> Else
>> ' Could not PACK
>> End If
>>
>> Bye, Olaf.