944,117 Members | Top Members by Rank

Ad:
Dec 5th, 2007
0

Searching database file in the application path in visual basic 6

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Light Poster
locsin is offline Offline
47 posts
since Aug 2007
Dec 5th, 2007
0

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

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. }
Reputation Points: 10
Solved Threads: 2
Light Poster
Mr.Wobbles is offline Offline
49 posts
since Jun 2007
Dec 5th, 2007
0

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

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]
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TechManDean is offline Offline
1 posts
since Apr 2007
Dec 8th, 2007
0

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

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
Reputation Points: 49
Solved Threads: 44
Posting Pro in Training
hkdani is offline Offline
426 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Input price
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: copy 200 workbooks from 1 directory with 200 subdirectory





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC