|
-
Oct 28th, 2000, 02:41 PM
#1
Thread Starter
Hyperactive Member
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...
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Oct 29th, 2000, 02:32 PM
#2
Thread Starter
Hyperactive Member
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
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
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???
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Oct 30th, 2000, 09:18 AM
#3
Thread Starter
Hyperactive Member
ok so i tried this
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
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...
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Nov 1st, 2000, 02:57 AM
#4
New Member
Hi PJB,
Have you tried:
objComm.CommandText = "Pack "+ thing
instead of
objComm.CommandText = "Pack (thing)"
L8r
-
Nov 1st, 2000, 06:35 AM
#5
Lively Member
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")
-
Nov 1st, 2000, 08:43 AM
#6
Thread Starter
Hyperactive Member
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
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
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!
VB6.0 SP4
Windows 2000
I'm thinking of a number between
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|