Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 25th, 2007, 01:20 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamilnadu, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default compacting database pblm

hi all:)
     my coding works correctly for compacting. but after opening any report (ie crystal report)it doesnt works.
           here the errror mentioned is
 error no 3049
         cannot open database(filename).it may not be a databse that your application recongnizes or file may corrupt.
  here is the code

         Public Sub Compact_DB(DBF_Path)
On Error GoTo disp_err
Dim FSO As New FileSystemObject

Dim tmp_file1
Dim tmp_file2
' First Close all the Databases

If Dir(App.Path & "\PA_COMPACT.00~") <> "" Then
   FSO.DeleteFile App.Path & "\PA_COMPACT.00~"
End If

If Dir(App.Path & "\PA_BK.BK") <> "" Then
   FSO.CopyFile App.Path & "\PA_BK.BK", App.Path & "\PA_BK.BK1", True
End If

If Dir(App.Path & "\PA_COMPACT.00~") <> "" Then
   FSO.DeleteFile App.Path & "\PA_COMPACT.00~"
End If
If Dir(App.Path & "\PAT_COMPACT.00~") <> "" Then
   FSO.DeleteFile App.Path & "\PAT_COMPACT.00~"
End If
tmp_file1 = App.Path & "\" & "PA_COMPACT" & ".00~"
tmp_file2 = App.Path & "\" & "PAT_COMPACT" & ".00~"

If Dir(DBF_Path) = "" Then
   tmp = MsgBox("The Database file at location : " & DBF_Path & " Not Found!!!" & vbLf & "Check the Server Status or Drive Mappings!!!", vbCritical, "Database Not Found!!!")
   Exit Sub
Else

   ''' Delete all the temporaty tables in the database

    If moConn.State = 1 Then
        moConn.Close
    End If

' moConn.Close
' moConn.Open

   DBEngine.CompactDatabase DBF_Path, tmp_file1
   'DBEngine.CompactDatabase DBF_Path1, tmp_file1
   ''Rename the Database to Original Name
   Rename_File tmp_file1, DBF_Path
   DoEvents
   tmp = MsgBox("Compacted Successfully.", vbExclamation, "Compact")
End If

Exit Sub
disp_err:
    tmp = MsgBox(Err.Description, vbCritical, "Compact : " & Err.Number)
    Exit Sub
End Sub

Public Function Rename_File(Old_Name, New_Name) As Boolean
' Rename the file. If new name already exists it deletes it.
On Error GoTo disp_err
Dim OldName, NewName
If Dir(New_Name) <> "" Then
   Kill New_Name
End If
OldName = Old_Name: NewName = New_Name ' Define file names.
DoEvents
Name OldName As NewName ' Rename file.
Rename_File = True
Exit Function
disp_err:
    tmp = MsgBox(Err.Description, vbCritical, "Rename : " & Err.Number)
    Rename_File = False
    Resume Next
End Function

help us..


Reply With Quote
  #2 (permalink)  
Old September 25th, 2007, 07:14 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. can you explain a little better when the error occurs? and where it happens?? it's not clear is the error is after compacting of before compacting or if you are trying to open a report after compacting...
and can you post the offending line??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #3 (permalink)  
Old September 26th, 2007, 05:11 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamilnadu, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default

hi sir
      iam not able to compact the database after opening a report.
here the errror mentioned is
 error no 3049
         cannot open database(filename).it may not be a databse that your application recongnizes or file may corrupt.
pls help us..


Reply With Quote
  #4 (permalink)  
Old September 26th, 2007, 07:22 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

so.. you have your database still openend, maybe you are not closing it after opening the report?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #5 (permalink)  
Old September 26th, 2007, 07:45 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamilnadu, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default

hi sir
     Thank u for ur kind response.how to close the database after opening the report through coding..giv me one example..
pls help us..



Reply With Quote
  #6 (permalink)  
Old September 26th, 2007, 07:49 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. that's depends on the report engine you are using and how are you opening the database.. is not a simple question ;)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #7 (permalink)  
Old September 27th, 2007, 06:34 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamilnadu, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default

hi sir
     Thank u for ur kind response. W

Reply With Quote
  #8 (permalink)  
Old September 27th, 2007, 06:35 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamilnadu, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default

hi sir
     Thank u for ur kind response. We are using crystal reports 10.
How to close the database after opening the crystal reports through coding..giv me one example..



Reply With Quote
  #9 (permalink)  
Old September 27th, 2007, 07:34 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

commmandobject.close?? that will close that object.. you will have to close any connection you opened so the database will close.. Still it could take a while since it really close, sometimes OS take time to flush caches and things like that..
Also could be that you are not closing the report and still it has a connection to the database.. you will have to check your code for this... there is no easy or direct answer for your problem...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compacting database Scootterp Access VBA 5 August 9th, 2006 09:33 AM
Compacting Access Database problem imaley SQL Language 1 April 23rd, 2004 11:28 AM
Compacting Access Database from code imaley Access 6 March 31st, 2004 05:33 PM
Automatically Compacting a Database nanohurtz Access 2 March 22nd, 2004 10:25 AM
Compacting a large database takabyte Classic ASP Databases 1 February 5th, 2004 12:58 PM



All times are GMT -4. The time now is 04:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.