CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2001
    Posts
    31

    Transfer txt files into sql db


    I have a big.. big question....

    Any idea about how can i transfer txt files from a vb application (im searching first on my directory or my network for all my txt files) into a "x" database sql server 7.0

    urgent!

    Thanks a lot!!!!!!!!!



  2. #2
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Re: Transfer txt files into sql db

    Are this arbitrary text documents that you want saved to a DB, or delimited text records?

    If the files are delimited text records think of using BULK INSERT. (Check the SQL Server documentation for more info)

    HTH


  3. #3
    Join Date
    Aug 2001
    Posts
    31

    Re: Transfer txt files into sql db

    Hi..
    Thanks for u response..

    but what i need is to use vb program or sentence.. to transfer file into a sql database

    Thanks---

    pd. the files are delimited by pipes


  4. #4
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Re: Transfer txt files into sql db

    My previous posting still applies:

    sSQL="BULK INSERT .." & sTableName & " FROM '" & sPath2TextFileWithExt & "'"
    sSQL=sSQL & " WITH (FORMATFILE = '" & sPath2FormatFileWithExt & "', DATAFILETYPE='char',TABLOCK)"
    con2DB.execute sSQL, lRecordsAdded, adExecuteNoRecords



    lRecordsAdded will return the number of records added (usually all or nothing).

    Check up with the SQL Server documentation on the structure of the format file (column mapping, width, separators, blah, blah). I also included a teaser of the possible options that can be specified in the WITH () clause of the BULK INSERT.

    Trust that the spoon feeding session will now lead you to the documentation.

    Apologies if the remarks seem snide, but what i need is...


  5. #5
    Join Date
    Aug 2001
    Posts
    31

    Re: Transfer txt files into sql db

    Thanks ...

    Let me try..!




  6. #6
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Oops forgot to mention

    The user that instantiated the connection MUST be a member of the sysadmins group.


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

Featured