HELP - Importing Text file into database 
Author Message
 HELP - Importing Text file into database

Does anyone know how to create an application in visual
basic, that will take a text file, parcel the information
and import the data into an Access database or table.

Please, let me know.

Paul



Sat, 10 Jan 2004 17:34:08 GMT  
 HELP - Importing Text file into database
Hope this helps

Private Sub cmdImport_Click()
Dim WayBill, PSID, DateShipped As String
Dim sql, sLine As String
Dim Cost As Double
Dim i As Integer

'CD is a common dialog control to find the file which is
on a floppy
    With CD
        .InitDir = "a:\"      'tell CD where to start
looking for the file
        .ShowOpen           'open CD
    End With
    'open flat file
    Open CD.FileName For Input As #1   ''open the text file

    Do While Not EOF(1)
        Line Input #1, sLine 'take the line into memory

'start parsing the line based on the length of my data and
put them into variables

        WayBill = Mid(sLine, 46, 12)
        Cost = CCur(Mid(sLine, 72, 6))
        DateShipped = "'" & ((Mid(sLine, 58, 8))) & "'"
        PSID = Trim((Mid(sLine, 66, 6)))

'create my sql statement

        sql = "Insert Into tblCourier
(Cost,DateShipped,waybill,datein) " _
        & "Values(" & (Cost * 1.1) * 0.675 & ", " &
DateShipped & ", " & WayBill & ", " & DateShipped & ")"
        'execute the  sql statement

'I am using a data environment control called de1  with a
connection object called conn2 connected to access 2k

        DE1.Conn2.Execute sql
        i = i + 1
    Loop  'loop to move to the next line and write the
data into the database
    'close flat file
    Close #1
    'display # of packages billed for
    MsgBox i & " packages processed!", vbInformation
End Sub

good luck

Quote:
>-----Original Message-----
>Does anyone know how to create an application in visual
>basic, that will take a text file, parcel the information
>and import the data into an Access database or table.

>Please, let me know.

>Paul

>.



Sun, 11 Jan 2004 04:38:43 GMT  
 HELP - Importing Text file into database
I do.

This is the job for kids.

--
Posted via CNET Help.com
http://www.help.com/



Sun, 11 Jan 2004 05:30:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Importing text from Text file- Help needed

2. Help - Schema file to import text file

3. Importing text files to a second database w/in Access

4. How to import text file to access database?

5. Import Text files to the database?

6. Importing Text File into DataBase Slow !

7. Importing Text File into DataBase Slow !

8. Importing text file into Access database via VB5

9. how to import text file into access database

10. Import Text File in database with ISAM driver

11. Import a text file to Database

12. Import Text file into VB Database Table?

 

 
Powered by phpBB® Forum Software