Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Pack dBase
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.odbcnet.


Ales Vojacek
GOOD ANSWER
Is there any way how to pack dBase file after delete rows.
Thank you Ales
Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Hussein Abuthuraya(MSFT)
GOOD ANSWER
Alex,

Using the DataAdapter.Update should physically remove the deleted rows fro mthe file. It scans all the rows and for each row in memory that has a "Deleted" RowState, the
DataAdapter will execute the proper DeleteCommand that is hooked to the DataAdapter.

I hope this helps!

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
ales vojacek
GOOD ANSWER
I don't think so, deleted rows are still in a dbf file
(the size of file is same as before delete). I think that
these rows have only deleted flag and are not physycaly
removed from the file.
Ales

[Original message clipped]

each row in memory that has a "Deleted" RowState, the
>DataAdapter will execute the proper DeleteCommand that is
hooked to the DataAdapter.
[Original message clipped]

FREE Security Tool Kit, please visit
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Hussein Abuthuraya(MSFT)
GOOD ANSWER
OK, I just tried that and here is how I got it to work:

Dim cn As New OdbcConnection("Driver={Microsoft Visual Foxpro Driver};SourceType=DBC;SourceDB=D:\VFOX_Data\data1.dbc;")
Dim cmd As OdbcCommand = New OdbcCommand("set Exclusive on;select * from dates;pack")
Try
cn.Open()
cmd.Connection = cn
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

I just tried that on a Foxpro table and it worked. The same should apply to the dbase file.

I hope that helps!

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Ales Vojacek
GOOD ANSWER
Thanks, but it is not Ok
Here is an error
Message    "ERROR [42000] [Microsoft][ODBC dBase Driver]
Invalid SQL statement;
expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE'."    string

[Original message clipped]

Driver};SourceType=DBC;SourceDB=D:\VFOX_Data\data1.dbc;")
> Dim cmd As OdbcCommand = New OdbcCommand("set
Exclusive on;select * from dates;pack")
[Original message clipped]

FREE Security Tool Kit, please visit
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Hussein Abuthuraya(MSFT)
GOOD ANSWER
You are using the dbase driver and my sample code that I tested uses the Visual FoxPro Driver. You need to use that driver so that you don't get the error.

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Ales Vojacek
GOOD ANSWER
I have to use FoxPro driver for DBase database??
Thank you for your help.

[Original message clipped]

that driver so that you don't get the error.
[Original message clipped]

FREE Security Tool Kit, please visit
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Hussein Abuthuraya(MSFT)
GOOD ANSWER
The Visual FoxPro driver works with dbase files and it solves some of the problems with the dbase ISAM driver. It looks like the file Pack problem is one of them.

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Ales Vojacek
GOOD ANSWER
Thanks it works, but when I try to insert any row into a
table using the foxpro driver it ends with error :
"ERROR [22018] [Microsoft][ODBC Visual FoxPro Driver]Data
type mismatch.".
Now I am using the FoxPro driver for pack database and the
dBase driver for inserting into tables.
Thanks a lot for your help.
Ales

[Original message clipped]

It looks like the file Pack problem is one of them.
[Original message clipped]

FREE Security Tool Kit, please visit
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
 
System.Data.Common.DataAdapter
System.Data.Odbc.OdbcCommand
System.Data.Odbc.OdbcConnection
System.Windows.Forms.MessageBox




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734