How to submit data from diff text files into database automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nudrat
    New Member
    • Aug 2007
    • 38

    How to submit data from diff text files into database automatically

    Hi,
    My problem is this i am collecting some information into .txt text files, now i have to submit those values in database daily.I am writing my code in asp,sql server database.

    I have one query::

    Can i write a job that can access text files and submit data.
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by nudrat
    Hi,
    My problem is this i am collecting some information into .txt text files, now i have to submit those values in database daily.I am writing my code in asp,sql server database.

    I have one query::

    Can i write a job that can access text files and submit data.
    Yes.

    As long as your text file data is formatted in a specific and consistent way that you know the length of strings you need to select, or if the data is deliminated with commas, spaces, etc something.

    Like this:
    Name,Address,Ho mePhone,Comment s
    Or
    Name Address HomePhone

    Then you need to use the File System Object to read each line of the text file in and populate variables, then write it to database using SQL.

    This is a simple read example of reading a text file. You will then need to use the VB String functions to extract individual data elements you will need. At the bottom is a link to various string extract functions
    [code=asp]
    Set fs=Server.Creat eObject("Script ing.FileSystemO bject")
    Set f=fs.OpenTextFi le(FileName, 1)
    do while f.AtEndOfStream = false
    Response.Write( f.ReadLine)
    Response.Write( "<br>")
    loop
    f.Close
    Set f=Nothing
    Set fs=Nothing

    [/code]


    MID Function Left Function

    Comment

    Working...