1 Replies - 5905 Views - Last Post: 17 November 2009 - 07:10 AM Rate Topic: -----

#1 vampyjoker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-November 09

how to import txt file into access database using vb6

Posted 16 November 2009 - 07:28 PM

Hi.. I'm require to modify this codes to import txt file into access database using vbscripts..

Private Sub Form_Load()
Dim dbMyDB As DAO.Database
Dim rsMyRS As DAO.Recordset
Dim sSourceFile As String
Dim sDestinationFile As String
Dim MyMail
Dim date1 As String
Dim filename As String
Dim WorkRS1 As Recordset
Dim SQL
Dim cnt As Integer
Dim vipcnt As Integer
Dim overallcnt As Integer ' control to determine whether there is any cert publishing today
Dim rptnonvipcnt As Integer
Dim rptvipcnt As Integer
Dim agencycnt As Integer
Dim vipsum As Integer
Dim nonvipsum As Integer
Dim Cur_agency As String
Dim mailsubj As String
Dim cmd As String



Set dbMyDB = OpenDatabase("c:\db\newsoe.mdb")
SQL = "Select * From Se2 order by agency"

Set rsMyRS = dbMyDB.OpenRecordset(SQL, dbOpenDynaset)
Set fso = New FileSystemObject
Set rpt = fso.OpenTextFile("C:\searchds\searchds.bat", ForWriting, True)

'intialise counters
cnt = 0
vipcnt = 0
overallcnt = 0
rptnonvipcnt = 0
rptvipcnt = 0
agencycnt = 0
vipsum = 0
nonvipsum = 0

If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
If (rsMyRS!pubdate = 0) And rsMyRS!notify = "N" Then
cmd = "call c:\searchds\querybyUID.bat 10.244.6.47"
cmd = cmd & " " & rsMyRS!agency & " " & rsMyRS!nric & " > c:\searchds\results\" & rsMyRS!nric & ".txt"
rpt.WriteLine cmd
'MsgBox cmd

cmd = " "

End If
rsMyRS.MoveNext
Loop
'cmd = "Call C:\Searchds\updatepubsearch.exe"
rpt.WriteLine cmd
'exit the program
rpt.Close
Set fso = Nothing
Unload Form1
End Sub




Kindly pls help me out..

Thanks..

Is This A Good Question/Topic? 0
  • +

Replies To: how to import txt file into access database using vb6

#2 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: how to import txt file into access database using vb6

Posted 17 November 2009 - 07:10 AM

Look over to the right under snippets at the "reading text file line by line" for opening and reading in the file or maybe the turorial on file handling.

In help look up...
FreeFile Function
Open Statement
Input Function
Line Input Function
Close Statement

Split Function
Arrays

Then look for the ADO tutorials. Especially ones that use the command object in conjunction with an insert statement. Once you have read all that you will have all the information you need to accomplish what you want to do except for the table name and field names to construct your insert statement and since you should have that information, you should have everything you need.



Good Luck
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1