Results 1 to 3 of 3

Thread: Writing text files to tables

  1. #1

    Thread Starter
    Addicted Member icemanmt78's Avatar
    Join Date
    May 2000
    Posts
    142

    Angry

    I need some help.

    I have been able to read in each line from a text file and format it correctly. Each line contains six value, i have got these stored in a string/int variables.

    What is the best way to write these to my table in an access/sql database.

    I can open the connection to the database etc its just the writing to a specific table.

    Any ideas??????

  2. #2
    Guest
    Hi, here is what we do in Visual Basic.

    1) This uses DAO...

    --code--

    dim db as database
    dim rs as recordset
    dim strquery as string

    set db = opendatabase("Your database complete path")
    strquery = "Select * from <your tablename> "
    set rs = db.openrecordset(strquery)

    --adding a record to the table--
    --for this add a record to the recordset instead--

    --firstly check if the table is empty--
    if not rs.recordcount = 0 then
    rs.movelast
    rs.movefirst
    end if

    --now add a new record--
    if not rs.recordcount = 0 then
    rs.addnew
    rs(0) = yourvariable1
    rs(1) = yourvariable2
    ...
    ...
    rs.update
    end if

    --thats it you have now added a record to ur table--

    2) The code would be similar if u r using ADO but the only change probably would be setting the connection instead of using opendatabase...

    all the best...vijay













  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Thumbs up Insert data...

    Use the INSERT.... VALUES SQL syntax.

    Cheers,

    Paul
    Not nearly so tired now...

    Haven't been around much so be gentle...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width