Jetcomp.exe

cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019 - 4 sept. 2007 à 16:15
cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019 - 4 sept. 2007 à 17:11
Bonjour,

Auriez-vous un exemple simple d'une fonction qui compact ou répare une base Acces via l'utilitaire jetcomp.exe ? Il suffirait de passer le passe de la base de données en question à la fonction pour quelle compact la base.
J'essai de le faire mais ça ne marche pas, j'en ai mareeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...
Merci d'avance de ce petit bout de code VB6 car je suis sur que quelqu'un à déjà fait ça pour son taff ou autres d'ailleur.
 

tolt

5 réponses

econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
4 sept. 2007 à 16:36
Salut,

Tu disposes de cet extrait de code dans la doc d'utilisation de jetcomp.exe.
Doc téléchargeable avec l'exécutable ICI





 








Copy and paste the following code into a
new Microsoft Access module and run the code. 
Note that this code will not work with Visual Basic because of the
CurrentDB call, but it can be easily modified to DAO’s OpenDatabase method.






 








Sub main()






    On
Error GoTo ErrorHandler






    Dim db
As DAO.Database, vBookMark As Variant, _






     
rsMSysCompactError As DAO.Recordset, strErrorTable As String, _






     
rsErrorTable As DAO.Recordset, fldErrorField As DAO.Field, _






     
strSQLSEL As String, strColumnValue As Variant, _






     
qdTemp As QueryDef, strSQLINS As String, intLoop As Integer, _






     
lngTableNameLength As Long, _






     
colErrorCollection As New Collection, intErrorCount As Integer






 









    Set db
= CurrentDb()






    ' Walk
through the MSysCompactError table to find rows that reflect






    ' lost
data values.






 
  Set rsMSysCompactError =
db.OpenRecordset("SELECT * FROM MSysCompactError WHERE ErrorRecId IS NOT
NULL", dbOpenDynaset)






   
intErrorCount = 0






    While
Not rsMSysCompactError.EOF






        '
Get the name of the table that had column data missing.






        strErrorTable
= rsMSysCompactError!ErrorTable






        '
Check to see that tablename is not greater than 48 characters






        '
to stay under 64 character tablename limit.






       
lngTableNameLength = Len(strErrorTable)






        If
lngTableNameLength > 48 Then






           
strErrorTable = Mid(strErrorTable, 1, 48)






           
' See if this truncated table name already exists.






           
On Error Resume Next






           
colErrorCollection.Add strErrorTable, strErrorTable






           
' If this already exists in the collection, then there is a






           
' duplicate table name.






           
If Err = 457 Then






               
' Truncate one more digit to append on the intErrorCount






               
' number to eliminate the duplicate table name.






               
strErrorTable = Mid(strErrorTable, 1, 47)






               
strErrorTable = strErrorTable & Mid((Str(intErrorCount)), 2, 1)






               
intErrorCount = (intErrorCount + 1)






           
End If






       
End If






       







        '
Get the bookmark value of the row that had lost column data.






       
vBookMark = rsMSysCompactError!ErrorRecId






        '
Open table that has lost column data.






       
Set rsErrorTable = db.OpenRecordset(strErrorTable, dbOpenTable,
dbReadOnly)






        '
Move to row that has lost column data.






       
rsErrorTable.Bookmark = vBookMark






        '
Start to build SQL string to call up in a table window.






       
strSQLSEL = "SELECT * INTO MSysCompactError" &
strErrorTable & " FROM " & strErrorTable & " WHERE
"






       
strSQLINS = "INSERT INTO MSysCompactError" & strErrorTable
& " SELECT * FROM " & strErrorTable & " WHERE "






       
intLoop = 0






       
For Each fldErrorField In rsErrorTable.Fields






           
strColumnValue = fldErrorField.Value






           
' Logic to build predicate based on various data types.






           
If Not IsNull(strColumnValue) Then






               
' Can't use ordinal as no guarantee of first column






               
' being zero.






               
' Check to see if this is the first column or not to






               
' build SQL statement.






               
If intLoop = 0 Then






                    If fldErrorField.Type =
dbDate Then






                        strSQLSEL = strSQLSEL
& "[" & fldErrorField.Name & "] = " &
"#" & strColumnValue & "#"






                        strSQLINS = strSQLINS
& "[" & fldErrorField.Name & "] = " &
"#" & strColumnValue & "#"






                    Else






                        If fldErrorField.Type dbText Or fldErrorField.Type dbChar Or fldErrorField.Type = dbMemo Then






                            strSQLSEL strSQLSEL & "[" & fldErrorField.Name & "] "
& "'" & strColumnValue & "'"






                            strSQLINS strSQLINS & "[" & fldErrorField.Name & "] "
& "'" & strColumnValue & "'"






                        Else






                            strSQLSEL strSQLSEL & "[" & fldErrorField.Name & "] "
& strColumnValue






                            strSQLINS strSQLINS & "[" & fldErrorField.Name & "] "
& strColumnValue






                        End If






                    End If






               
Else






      
             If fldErrorField.Type = dbDate
Then






                        strSQLSEL = strSQLSEL
& " AND " & "[" & fldErrorField.Name &
"] = " & "#" & strColumnValue & "#"






                        strSQLINS = strSQLINS
& " AND " & "[" & fldErrorField.Name &
"] = " & "#" & strColumnValue & "#"






                    Else






                        If fldErrorField.Type dbText Or fldErrorField.Type dbChar Or fldErrorField.Type = dbMemo Then






                            strSQLSEL =
strSQLSEL & " AND " & "[" & fldErrorField.Name
& "] = " & "'" & strColumnValue &
"'"






                            strSQLINS =
strSQLINS & " AND " & "[" & fldErrorField.Name
& "] = " & "'" & strColumnValue &
"'"






                        Else






                            strSQLSEL =
strSQLSEL & " AND " & "[" & fldErrorField.Name
& "] = " & strColumnValue






                            strSQLINS =
strSQLINS & " AND " & "[" & fldErrorField.Name
& "] = " & strColumnValue






                        End If






                    End If






               
End If






           
End If






           
intLoop = (intLoop + 1)






           
' QJet limitation for maximum conditions is reached.






           
If intLoop = 39 Then






               
Exit For






           
End If






       
Next fldErrorField






        On
Error Resume Next






  
     ' Create error table if it does not exist.






       
db.Execute strSQLSEL, dbFailOnError






        If
Err = 3010 Then






           
On Error GoTo ErrorHandler






           
' Add rows to error table if it already exists.






           
db.Execute strSQLINS, dbFailOnError






       
End If






       
rsErrorTable.Close






       
rsMSysCompactError.MoveNext






    Wend






   
rsMSysCompactError.Close






    MsgBox
"Done!"






    Exit
Sub





ErrorHandler:






    MsgBox
"An error has occurred " & Err & " " & Error






    Resume
Next





End Sub



















Manu


--------------------------------------------------------------------------------------------
Avant de poster un message, n'oubliez pas de consulter le reglement.
0
cs_Exploreur Messages postés 4821 Date d'inscription lundi 11 novembre 2002 Statut Membre Dernière intervention 15 novembre 2016 15
4 sept. 2007 à 16:37
Salut,

Voir ici...lol...

A+
Exploreur

 Linux a un noyau, Windows un pépin

 
0
cs_Exploreur Messages postés 4821 Date d'inscription lundi 11 novembre 2002 Statut Membre Dernière intervention 15 novembre 2016 15
4 sept. 2007 à 16:38
Salut,

Econs >> T'es trop rapide...lol

A+
Exploreur

 Linux a un noyau, Windows un pépin

 
0
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
4 sept. 2007 à 16:41
Tout tapé à la main, de tête ... j'espère que c'est bon

Manu
--------------------------------------------------------------------------------------------
Avant de poster un message, n'oubliez pas de consulter le reglement.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019
4 sept. 2007 à 17:11
J'ai vu ce code mais trop complexe pour moi.
Personnel à une fonction qui gére l'exécution direct de jetcomp.exe via un VB6 ?

tolt
0
Rejoignez-nous