Anyone have any idea how you can pack a Visual Fox Pro .dbc file from VB(mainly being able to pack all the dbf's within the dbc)??
I figured out the connection string to the dbc file itself but have no clue on what to do after that...
Printable View
Anyone have any idea how you can pack a Visual Fox Pro .dbc file from VB(mainly being able to pack all the dbf's within the dbc)??
I figured out the connection string to the dbc file itself but have no clue on what to do after that...
Ok so i figured out how to connect to the .dbc files and PACK a single table but i can't figure out code to loop through all the tables and pack them. Here is the code i am using
this works fine as long as i put one of the .dbf names in for "TableName" but i need it to go through and do each one (over 165 tables altogether)Code:Dim objConn As ADODB.Connection
Dim objComm As ADODB.Command
Private Sub Form_Load()
Set objConn = New ADODB.Connection
objConn.ConnectionString = "DSN=Visual FoxPro Database;UID=;PWD=;SourceDB=C:\Vista\DATA\Ny\VISTA.DBC;SourceType=DBC;Exclusive=Yes;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
objConn.Open
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandText = "Pack TableName"
objComm.CommandType = adCmdText
objComm.Execute
End Sub
any hints even???
ok so i tried this
but that gives me an error stating that "Variable 'THING' was not found?Code:Dim objConn As ADODB.Connection
Dim objComm As ADODB.Command
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set objConn = New ADODB.Connection
objConn.ConnectionString = "DSN=Visual FoxPro Database;UID=;PWD=;SourceDB=C:\Vista\DATA\Ny\VISTA.DBC;SourceType=DBC;Exclusive=Yes;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
objConn.Open
Set rs = objConn.OpenSchema(adSchemaTables)
Do Until rs.EOF
If rs("TABLE_TYPE") = "TABLE" Then
Set thing = rs("TABLE_NAME")
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandText = "Pack (thing)"
objComm.CommandType = adCmdText
objComm.Execute
End If
rs.MoveNext
Loop
MsgBox " Process Complete! "
End Sub
You guys can jump in anytime here, not that i really mind my own personal thread...
Hi PJB,
Have you tried:
objComm.CommandText = "Pack "+ thing
instead of
objComm.CommandText = "Pack (thing)"
L8r
Close, but no cigar.
"thing" is an object within your program. You cannot simply pass it as is.
You need
obj.commandtext = "Pack " & rs("TABLE_NAME")
actually it tried both those and for some reason it still refused to take the variable, i did find something that worked, it's kinda silly but it does the trick.
I set a textbox = the rs!TABLE_NAMES and for some reason the pack command would read TEXT1.text as a variable, heres the code
only other wierd thing is for the progress bar i couldn't get it to set to a percentage, i tried ProgressBar1.Value = rs.PercentPosition of course but it didn't like that, guess ya can't have everything...Code:Dim objConn As ADODB.Connection
Dim objComm As ADODB.Command
Dim rs As ADODB.Recordset
Private Sub Pack()
On Error GoTo ErrorHandler
Label1.Caption = "Auburn, NY Database Optimizing..."
Label1.Refresh
Set objConn = New ADODB.Connection
objConn.ConnectionString = "DSN=Visual FoxPro Database;UID=;PWD=;SourceDB=V:\DATA\Ny\VISTA.DBC;SourceType=DBC;Exclusive=Yes;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
objConn.Open
Set rs = objConn.OpenSchema(adSchemaTables)
Do Until rs.EOF = True
ProgressBar1.Value = rs.AbsolutePosition
Text1.Text = rs!TABLE_NAME
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandText = "Pack '" & Text1.Text & "' "
objComm.CommandType = adCmdText
objComm.Execute
rs.MoveNext
Loop
rs.Close
objConn.Close
ProgressBar1.Value = 140
Exit Sub
ErrorHandler:
MsgBox " Something went horribly wrong!!! Have a nice day! "
End Sub
Thanx for the replies!