Using VB6
Now I am using a Browse button in my software to select the text file, then it is converted in to mdb (access). I don’t want to select the text file.
Once I installed my software in any system, the text file should automatically select in a specified path. Then the text file automatically converts into mdb. Once converted in to mdb then
Vb Code for converting text to mdb.
Dim db As Database, tbl As TableDef
Set db = DBEngine.OpenDatabase(App.Path & "\History.mdb")
Set tbl = db.CreateTableDef("Temp")
tbl.Connect = "Text;database=" & App.Path & "/ConvTemp/"
tbl.SourceTableName = strOutput & ".txt"
db.TableDefs.Append tbl
db.Execute "Select Temp.ID, Temp.IDTerminal, Temp.Reader, Temp.Date, Temp.Time, Temp.Cardnumber into " & strOutput & " from Temp"
db.TableDefs.Delete ("Temp")
db.Close
MsgBox strOutput
sql2 = "insert into events select * from " & strOutput & ""
If rs.State = 1 Then rs.Close
rs.Open sql2, Cn, adOpenStatic, adLockOptimistic
Set tbl = Nothing
Set db = Nothing
Above code is working for text to mdb conversion. But I need to convert the text file automatically without using browse button.
For Example
MDB Name is – History.mdb and table name is – event.mdb
I set a path like this “C:\NewFolder” In my software
In the above folder, the text file will appear with different names. May be per day text file will appear 10 to 20 text files with new different names. I cannot able to give the text file name also. I have to give only the extension like (*.txt).
Once I installed my software, the Software should select the text file from c:\NewFolder, then it automatically converts in to mdb, after converted the text file the text file should delete automatically.
Expected Output
Once I installed my software in any system, the software should select the text file from the specified folder, then the text file convert into mdb. Once converted, the text files automatically delete from the specified path.
For converting text to mdb am having the code, for automatically selecting the text file I need a sample code or idea’s
Am new to VB6, Can any one give some idea how to do this. Or can any post a sample code for automatically selection of text file.
Please.