Compressing Access-95 table thru VB.NET


Hi,
Question1.
   Using VB.NET( or C#) , how can I compress an Access-95 table ?
 (This can be considered as a windows application. But ultimately, this EXE  has to be in a schedule that is run once in a week).

Question2.
  Actually there is a windows service running in the back which  , in every 10 minutes deletes almost all rows in the  Access table (same table which has to be compressed once in a week) . Do we have to do anything additionally, considering the possibility that  the  EXE in the schedule will run to compress the table at the same time when the windows service is deleting the rows in the table?  
                                   
                                        Thanking you
sgs1970Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
You still have to use DAO or ADO because .Net does not gives you this feature.

See http://www.knowdotnet.com/articles/compactmdb.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
iboutchkineCommented:
Add ref to Microsoft Jet replication Objects lib
Jet OLEDB:Engine Type = 4 - for Access97
Jet OLEDB:Engine Type = 5 - fro Access 2000
============================================


Imports System.IO.File


  Private Sub CompactDatabase()
        Dim jro As New JRO.JetEngine
        Dim sConnSource As String
        Dim sConnDestination As String

        'compact db to temp.mdb

        sConnSource = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & DBPATH & ";Jet OLEDB:Engine Type = 4"

        sConnDestination = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & DBPATHONLY & "temp.mdb;Jet OLEDB:Engine Type = 4"

        Try
            jro.CompactDatabase(sConnSource, sConnDestination)
            Delete(DBPATH) 'delete db(System.IO.FIle)
            Copy(DBPATHONLY & "temp.mdb", DBPATHONLY & "CheckRec.mdb")
            Delete(DBPATHONLY & "temp.mdb")
        Catch
            MessageBox.Show("Cannot compact database. It might be open by another user.", "Error Compacting", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
========================================================

another example


Sub Main()

        Dim jro As JRO.JetEngine

        jro = New JRO.JetEngine()

        jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb", _
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NewNwind.mdb;Jet OLEDB:Engine Type=4")

        MsgBox("Finished Compacting Database!")
End Sub

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.