PDA

Click to See Complete Forum and Search --> : any clue???


PJB
Oct 28th, 2000, 02:41 PM
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...

PJB
Oct 29th, 2000, 01:32 PM
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

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

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)

any hints even???

PJB
Oct 30th, 2000, 08:18 AM
ok so i tried this

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


but that gives me an error stating that "Variable 'THING' was not found?

You guys can jump in anytime here, not that i really mind my own personal thread...

Nemo
Nov 1st, 2000, 01:57 AM
Hi PJB,

Have you tried:

objComm.CommandText = "Pack "+ thing

instead of

objComm.CommandText = "Pack (thing)"

L8r

Orpheus
Nov 1st, 2000, 05:35 AM
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")

PJB
Nov 1st, 2000, 07:43 AM
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


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;Co llate=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


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...

Thanx for the replies!