Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to reindex and pack from executable
Message
De
09/09/2004 11:50:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/09/2004 10:36:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00940642
Message ID:
00940680
Vues:
15
>Hello Cetin,
>
>Please Can you help me on this:
>
>I am working on VB with Foxpro table.
>
>I am using oledb connection object with free table.
>
>Please can you tell me how can i reindex a table and pack via Visual Basic application.
>The problem is i upload loads of record into ocdata.dbf table, using the Loop:
>Every now and then the table gets corrupted: while it is uploading the records. After uploading between 240 and 256 record's to the table the table gets corrupted and it stops and i have the validations which alerts me saying the table might be corrupted.
>If there is a way to reindex and pack the table via VB to foxpro dbf, then i will do it for every trun in the loop.
>
>My Table name is ocdata.dbf
>Located at c:\dataset\ocdata.dbf
>
>Following is the code I am using:
>
>**************Code***************
> Set oconn = New ADODB.Connection
> oconn.CursorLocation = adUseClient
>oconn.ConnectionString = "Provider=vfpoledb.1;
> DataSource=c:\dataset\;Collating Sequence=general"
> oconn.Open
>
> sql = "Select * from ocdata where ocdata.ID = (Select max(ocdata.id) from ocdata)"
>Set rsocd = New ADODB.Recordset
>rsocd.Open sql, oconn, adOpenStatic, adLockOptimistic, adCmdText
>
> rsocd.AddNew
> rsocd!id = newno
> If Item2 <> "" Then
> rsocd!tiffile = Trim(FItem2)
> End If
> If s <> "" Then
> rsocd!ocdata = Trim(s)
> End If
> rsocd!created_dt = Date
> rsocd.Update
>**************************************************
>Thank you very much, Cetin.

Raj,
I don't know VB enough to help on this. However even in my limited knowledge with VB this code looks weird to me. A table having corruption every 240-250 records is suspect. I have never done such a view in VFP to insert records into so I suspect the culprit is there.
Wouldn't this be more accurate (code might be buggy due to almost 0 level VB - what's newno BTW a constant, proc call?) :
Set oconn = New ADODB.Connection
oconn.CursorLocation = adUseClient
oconn.ConnectionString = "Provider=vfpoledb;DataSource=c:\dataset\"
oconn.Open
oConn.Execute("set null off")
oConn.Execute("insert into ocdata (id,tiffile,ocdata,created_dt) values (" & _
 newno & ",'" & FItem2 & "','" & s & "',Datetime())")
oConn.Close
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform