| | |
Searching database file in the application path in visual basic 6
![]() |
•
•
Join Date: Aug 2007
Posts: 47
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jun 2007
Posts: 49
Reputation:
Solved Threads: 2
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
If(System.IO.File.Exists(path As String) = true){ MsgBox( message As String ) }else{ FileCopy(Source As String, Destination As String) }
Mr.Wobbles~
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Solved Threads: 0
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]
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]
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)
Option Explicit Dim fso As FileSystemObject Private Sub Form_Load() Dim strFileName As String Set fso = New FileSystemObject strFileName = Text1.Text If fso.FileExists(strFileName) Then MsgBox "Blah, Blah, Blah, the File exists", vbInformation, "File Status" Else MsgBox "Blah, Blah, Blah, the File does not exist.", vbInformation, "File Status" End If Set fso = Nothing End Sub
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Input price
- Next Thread: copy 200 workbooks from 1 directory with 200 subdirectory
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





