Searching database file in the application path in visual basic 6

Reply

Join Date: Aug 2007
Posts: 47
Reputation: locsin is an unknown quantity at this point 
Solved Threads: 0
locsin locsin is offline Offline
Light Poster

Searching database file in the application path in visual basic 6

 
0
  #1
Dec 5th, 2007
Season Greetings!

Searching database file in the application path

I want to determine the database file is existing or not... If the database (".mdb") is existing then msgbox "The database .mdb is not existing" if not existing msgbox " The database is not existing"

If the database is not existing... how to copy file of the existing database.

tnx in advance
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 49
Reputation: Mr.Wobbles is an unknown quantity at this point 
Solved Threads: 2
Mr.Wobbles Mr.Wobbles is offline Offline
Light Poster

Re: Searching database file in the application path in visual basic 6

 
0
  #2
Dec 5th, 2007
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If(System.IO.File.Exists(path As String) = true){
  2. MsgBox( message As String )
  3. }else{
  4. FileCopy(Source As String, Destination As String)
  5. }
Mr.Wobbles~
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1
Reputation: TechManDean is an unknown quantity at this point 
Solved Threads: 0
TechManDean TechManDean is offline Offline
Newbie Poster

Re: Searching database file in the application path in visual basic 6

 
0
  #3
Dec 5th, 2007
System.IO.File.Exists is for .NET will not work in old VB versions
but here's a VB6 solution that works in my code.
[code]
Dim dir_str As String
'check if database exists (My_Database is a fully formed path+name)
dir_str = Dir(My_Database)
If dir_str = "" Then
FileCopy My_DatabaseCopy, My_Database 'no database, get copy
Else
MsgBox "Database " & My_Database & " is ready."
End If
[\code]
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Searching database file in the application path in visual basic 6

 
0
  #4
Dec 8th, 2007
You need to use The File System Object. Add the Microsoft scripting runtime dll in your Project reference menu, first.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2. Dim fso As FileSystemObject
  3. Private Sub Form_Load()
  4. Dim strFileName As String
  5. Set fso = New FileSystemObject
  6. strFileName = Text1.Text
  7. If fso.FileExists(strFileName) Then
  8. MsgBox "Blah, Blah, Blah, the File exists", vbInformation, "File Status"
  9. Else
  10. MsgBox "Blah, Blah, Blah, the File does not exist.", vbInformation, "File Status"
  11. End If
  12. Set fso = Nothing
  13. End Sub
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC