2007/Apr/16

วิธีที่ 1
SET TABLEVALIDATE TO 0
USE tablename (ที่เสีย)
APPEND BLANK
DELETE
PACK
SET TABLEVALIDATE TO 3
USE

และวิธีที่สอง
ให้สร้างไฟล์โมดูลขึ้นมาตัวหนึ่ง เอาไว้เก็บ procedure/function ที่ใช้ประจำ
ก๊อปปี้ซอร์สข้างล่างทั้งหมดไปไว้ที่ module ไฟล์ที่สร้างขึ้น
ตอนเรียกใช้ module ให้ใช้คำสั่ง set proc to ชื่อโมดูล.prg
ก่อนซ่อมตารางทุกเครื่องต้องปิดไฟล์นั้นก่อน
คำสั่งที่ใช้ในการซ่อมตารางที่ corrupted คือ
do WinRepairData with 'drive:\พาธ\ชื่อไฟล์.dbf'
เสร็จแล้วก็ลอง use ว่าได้ไหม ถ้าไม่ได้แสดงว่าไฟล์มีคนอื่นเปิดค้างอยู่ ปิดให้หมดแล้ว repair ใหม่
*************************************
procedure WinRepairData
Lparameters tcDBF
Local handle, lnFileSize, lnReccount, lnHeaderSize, lnRecordSize, ;
lnCalculatedReccount, llHasMemo
handle=fopen(tcDBF,12) && Opened readwrite
lnFileSize = fseek(handle,0,2) && Get file size
* Read header info
lnReccount = ReadBytes(handle, 4,4)
lnHeaderSize = ReadBytes(handle, 8,2)
lnRecordSize = ReadBytes(handle,10,2)

lnCalculatedReccount = floor((lnFileSize-(lnHeaderSize+1))/lnRecordSize)
If lnCalculatedReccount # lnReccount && If calculated # recorded fix it
WriteBytes(handle, 4,4,lnCalculatedReccount)
endif
=fclose(handle)
endproc

function WriteBytes
Lparameters tnHandle, tnPos, tnSize, tnNumber, tlLR
Local lcString, lnLowDword, lnHighDword,ix
lcString=''
If tlLR
For ix=tnSize-1 to 0 step -1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Else
For ix=0 to tnSize-1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Endif
=fseek(tnHandle, tnPos,0) && Go to Pos
Return fwrite(tnHandle,lcString)
endfunc

function ReadBytes
Lparameters tnHandle, tnPos, tnSize, tlLR
Local lcString, lnRetValue,ix
=fseek(tnHandle, tnPos,0) && Go to Pos
lcString = fread(tnHandle, tnSize) && Read tnSize bytes
lnRetValue = 0
For ix=0 to tnSize-1 && Convert to a number
lnRetValue = lnRetValue + asc(substr(lcString,ix+1)) * ;
iif(tlLR,256^(tnSize-1-ix),256^ix)
Endfor
Return int(lnRetValue)
endfunc
คัดลอกมาจาก
http://www.songkwae.com/foxboard/display_topic_threads.asp?ReturnPage=Thread&ForumID=3&TopicID=363&PagePosition=3&ThreadPage=1
http://www.songkwae.com/foxboard/question.asp?QID=8350
http://www.songkwae.com/foxboard/question.asp?QID=6158
ทดลองดูนะครับ ผมใช้ได้มาแล้วแน่นอนทั้งสองแบบ
ชื่อ: 
เว็บไซต์: 
คอมเมนต์:




smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
ลองใช้วิ่งที่ 1 แล้ว work คะ
ขอบคุณมากๆเลยคะdouble wink
#1  by  สุธาสินี (124.120.173.32) At 2008-07-01 17:24, 
HarrumphIf you lsitened to R4's The World at One there was a near punch up involving the McNulty who was very tetchy and the Conservative spokesperson. ,
#2  by  rHvReXxcdh (81.82.132.186) At 2009-10-23 09:15, 

<< Home