Page 1 of 1
Error DBCMD/2001 Workarea not in use: ORDLISTADD
Posted: Mon Nov 14, 2011 7:57 am
by huangchenmin
Hello everyone:
Here is the story. I defined a schedule task with windows, and run my application at 12:20 every mon~Fri.
『Error DBCMD/2001 Workarea not in use: ORDLISTADD』keeps coming out on and off. I pretty sure that casue is no because of using by someone else at same time.
What else going worng?
Please Help!
sincerely chen min
Following are whole message
Date:11/14/11 Time: 12:20:01
Error DBCMD/2001 Workarea not in use: ORDLISTADD
Called from ORDLISTADD(0)
Called from DBSETINDEX(0)
Called from OPENDB(1107)
Called from WHENSTART$(757)
Following are partical source code
init function WhenStart()
set softseek OFF
set delete ON
Local m_driver:=upper(left(GetCurrentFolder(),1))
if m_driver=='J'
OpenDBt()
elseif m_driver=='X'
OpenDB()<-----------line 757
else
MsgInfo('無法開啟資料庫,按確定結束!','WhenStart()')
Form_upload.RELEASE
endif
return
OpenDB() and OpenDBt() are complete same.
OpenDB()
IF file("X:\DM_UPLOAD\ULHI01.ntx") .and. file("X:\DM_UPLOAD\ULHI02.NTX");
.and. file("X:\DM_UPLOAD\ULHI03.NTX") .and. file("X:\DM_UPLOAD\ULHI04.NTX");
.and. file("X:\DM_UPLOAD\ULHI05.NTX")
USE X:\DM_UPLOAD\ULHIS INDEX;
X:\DM_UPLOAD\ULHI01,;
X:\DM_UPLOAD\ULHI02,;
X:\DM_UPLOAD\ULHI03,;
X:\DM_UPLOAD\ULHI04,;
X:\DM_UPLOAD\ULHI05 EXCLUSIVE<------line 1107
if neterr()
msginfo("Fail to open database, someone is using it!")
close
endif
ELSE
ENDIF
......
return
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Mon Nov 14, 2011 2:29 pm
by l3whmg
Hi
first of all I suggest to you to use this function (and related) to open table DBUSEAREA(....)
Little example
Code: Select all
LOCAL cFileName := hb_fnameMerge( cSomePath, cTableName, "dbf" )
LOCAL cAlias := cTableName // as you prefer
LOCAL lNewArea := .T. // as you prefer
LOCAL lNotShared := .F. // as you prefer
LOCAL lReadOnly := .F. // as you prefer
DBUSEAREA( lNewArea, DBSETDRIVER(), cFileName, cAlias, lNotShared, lReadOnly )
and bout ORDLISTADD, little example
Code: Select all
LOCAL cFileName
cFileName := hb_fnameMerge( cSomePath, "index1", "ntx" )
ORDLISTADD( cFileName )
cFileName := hb_fnameMerge( cSomePath, "index2", "ntx" )
ORDLISTADD( cFileName )
etc
ORDSETFOCUS(1) // or 2 or 3
As yu can see I always used cSomePath. You can create it as you prefer and then it's the same for table (dbf) and index (ntx). This can be an
About yor problem: before use OpenDbt() and OpenDb() all table area closed? Do you use the same alias? Are you shure only one time OpenDbt() OR opneDb() are execute......about commands _SET_* ?
Why do you write two functions and they do the same things?
Cheers
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Mon Nov 21, 2011 9:55 am
by huangchenmin
l3whmg wrote:Hi
first of all I suggest to you to use this function (and related) to open table DBUSEAREA(....)
Little example
...
Cheers
Dear l3whmg:
Sorry for replying so late.
Thanks for you help, and it is reall helpful.
After 'Hunting' for couples of days. Finally I knew the reason why the errors occures!
My boss using the application while I set database exclusived for synchronization.
I coding and testing in usb disk, so I make opendb() and opendbt() for real run and testing.
I let application tell which one to call while run from server or usb disk. Thus I don't have to switch for.
Thanks again for you help.
Sincerely chen min
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Mon Nov 21, 2011 2:45 pm
by l3whmg
Hi Chen Min,
no problem for "late". I'm happy you found the problem and I want add these to help you again
A simple function related with previous example:
Code: Select all
nSecondsToWait := 3 // or 5.....
lOpen := .F.
IF SELECT( cAlias ) <= 0
DO WHILE .T.
DBUSEAREA( lNewArea, DBSETDRIVER(), cFileName, cAlias, lNotShared, lReadOnly )
IF nSecondsToWait <= 0
EXIT
ELSEIF NETERR()
nSecondsToWait -= 1
INKEY( 1 )
ELSE
lOpen := .T.
EXIT
ENDIF
ENDDO
IF lOpen == .F.
YourErrorHandler( "Can't open table" ) <====(1)
ENDIF
ELSE
YourErrorHandler( "Alias already in use" )
ENDIF
RETURN lOpen // can be .T. or .F.
(1) here you can intercept errors while opening a table. And this include sharing/exclusive problem.
Cheers
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Tue Nov 22, 2011 12:44 am
by huangchenmin
l3whmg wrote:Hi Chen Min,
no problem for "late". I'm happy you found the problem and I want add these to help you again
......
Cheers
Dear l3whmg:
Thank you very very much about those samples for me.
I don't figue out how nSecondsToWait got value for it ?
Could you explain it to me? Please.
Sincerely chen min
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Tue Nov 22, 2011 9:22 am
by l3whmg
Hi Chen Min.
Firts of all: this is one solution, there are many other as you prefer.
First: you are within a loop and you are trying to open a table
Code: Select all
DO WHILE .T.
DBUSEAREA( lNewArea, DBSETDRIVER(), cFileName, cAlias, lNotShared, lReadOnly )
ENDDO
When it will be ended?
A) when a simple timer is finished
B) when table is opened
C) about this
Code: Select all
ELSEIF NETERR()
nSecondsToWait -= 1
INKEY( 1 )
There are many reasons to receive an error: ie an index rebuild. So: I wait a while and then I retry to open (3 or 5 secs for example).
I suggest to you to remember: write your programs thinking to be in a network where several users can do more actions based upon your code. For example: I write my programs without using reindex because it requires "exclusive" opening; for me this is a special event and must be done with database closed for end users. But this it is my opinion.
Cheers
p.s. you can use the same concept with RLOCK()......
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Sat Nov 26, 2011 2:26 pm
by huangchenmin
huangchenmin wrote:l3whmg wrote:Hi Chen Min,
no problem for "late". I'm happy you found the problem and I want add these to help you again
...
Sincerely chen min
Thanks again!
Being very helpful to me.
Sincerely chen min
Re: Question about 『Error DBCMD/2001 Workarea not in use: OR
Posted: Sat Jan 14, 2012 12:13 am
by JosK
i had the same error with virtualgrid
Function MaakBrowseDbf1()
use dbf1.dbf
MaakBrowse()
Function MaakBrowseDbf2()
use dbf2.dbf
MaakBrowse()
Function MaakBrowse()
local o
o:=Virtualgrid:New()
o:workarea:=alias()
This gives the error.
The solution is:
select 1
use dbf1
select 2
use dbf2
huangchenmin wrote:Hello everyone:
Here is the story. I defined a schedule task with windows, and run my application at 12:20 every mon~Fri.
『Error DBCMD/2001 Workarea not in use: ORDLISTADD』keeps coming out on and off. I pretty sure that casue is no because of using by someone else at same time.
What else going worng?
Please Help!
sincerely chen min
Following are whole message
Date:11/14/11 Time: 12:20:01
Error DBCMD/2001 Workarea not in use: ORDLISTADD
Called from ORDLISTADD(0)
Called from DBSETINDEX(0)
Called from OPENDB(1107)
Called from WHENSTART$(757)
Following are partical source code
init function WhenStart()
set softseek OFF
set delete ON
Local m_driver:=upper(left(GetCurrentFolder(),1))
if m_driver=='J'
OpenDBt()
elseif m_driver=='X'
OpenDB()<-----------line 757
else
MsgInfo('無法開啟資料庫,按確定結束!','WhenStart()')
Form_upload.RELEASE
endif
return
OpenDB() and OpenDBt() are complete same.
OpenDB()
IF file("X:\DM_UPLOAD\ULHI01.ntx") .and. file("X:\DM_UPLOAD\ULHI02.NTX");
.and. file("X:\DM_UPLOAD\ULHI03.NTX") .and. file("X:\DM_UPLOAD\ULHI04.NTX");
.and. file("X:\DM_UPLOAD\ULHI05.NTX")
USE X:\DM_UPLOAD\ULHIS INDEX;
X:\DM_UPLOAD\ULHI01,;
X:\DM_UPLOAD\ULHI02,;
X:\DM_UPLOAD\ULHI03,;
X:\DM_UPLOAD\ULHI04,;
X:\DM_UPLOAD\ULHI05 EXCLUSIVE<------line 1107
if neterr()
msginfo("Fail to open database, someone is using it!")
close
endif
ELSE
ENDIF
......
return