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,HomePhone,Comments
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
-
Set fs=Server.CreateObject("Scripting.FileSystemObject")
-
Set f=fs.OpenTextFile(FileName, 1)
-
do while f.AtEndOfStream = false
-
Response.Write(f.ReadLine)
-
Response.Write("<br>")
-
loop
-
f.Close
-
Set f=Nothing
-
Set fs=Nothing
-
-
MID Function Left Function