problems with compacting

  • Thread starter Thread starter Selva Chinnasamy
  • Start date Start date
S

Selva Chinnasamy

I have had problems with Inserting records then I found the KB article which
has solution
http://support.microsoft.com/?id=884185

Now I am trying to compact the database, used JRO to compact the database,
compacting works fine.

But noticed that after compacting I get an error "can not update, update
failed".

Any help to resolve the error, or any other work around is greatly
appreciated.

Selva
 
Hi Selva,

Could you post the code you use to update the database? Also, please also
post the error code, and all error messages. So that I do some more
research on this issue. Thank you!

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Kevin, Below is the code, I use to compact the database. Some times insert
roes works fine, but some times I get an error message "Unable to Update"
when I try to add a row to the table.

Dim db_name As String = a_Path
Dim temp_name As String = a_Path & ".temp"
Dim jro As JRO.JetEngine
jro = New JRO.JetEngine

If System.IO.File.Exists(temp_name) = True Then
Kill(temp_name)
End If

jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
db_name, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + temp_name + ";Jet
OLEDB:Engine Type=5")

Kill(db_name)
Rename(temp_name, db_name)
System.Runtime.InteropServices.Marshal.ReleaseComObject(jro)

Thanks In Advance
Selva
 
Hi Selva,

When conpacting the database, you only need to specify the filename,
provider is not a requirement. But this is fine. I didn't see any other
problem in your compacting code.

In your post, you mentioned the Cannot Update error is get sometimes. Is
there any particular circumstances that generates this error? Is this error
from the Access database? If so, if you add data to Access table manually,
will you get this error again?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Selva,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support

==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Kevin, Thanks for checking, I haven't found the solution yet.



All I like to know is how to compact the database, if the code I have
attached in my previos email isn't right.



Compacting database doesn't give any problems to me, inserting records to
the table is failing. I am trying to resolve the error with Access 2003 and
AutoNumber as posted in http://support.microsoft.com/?id=884185



Selva
 
Hi Selva,

To compact an Access database, you can try to call DBEngine.CompactDatabase
in DAO instead of JRO. Here is an example:

http://www.developerfusion.co.uk/show/4142/

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Selva,

Does this answer your question? Anything I can do to help?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top