Jump to content

storing text file content into mysql


yklxmas

Recommended Posts

Hiya,I'm just wondering if anyone can help me on this problem.I've got a text file and its content format is something like below00ABCDEF01ABCDEFGGGK3011ABCDEFKBasically, I would like to store them in its format in mysql. I've manually added the contents and called it in its format. However, I tried using ASP code but it just becomes a long string of text.Any idea how I can insert this into database?Many thanks in advance

Link to comment
Share on other sites

Check out the TextStream reference - specifically the step entitled "Read all lines from a textfile". It'll show you how you can read each line of a text file, one line at a time. Once you have each individual line, you can insert them, one at a time, into your database.

Link to comment
Share on other sites

Basically,The standard code to open up text file.In the loop to read every line,I code it liketextline = textline & textObject.readLineI can tell that this is wrong. Because I will end up with one long long long string without line break. Anyone knows how to store line by line in the same field. Cheers

Link to comment
Share on other sites

Like this?

Set fs=Server.CreateObject("Scripting.FileSystemObject")Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)do while f.AtEndOfStream = falsetextline = textline & f.ReadLine & "<br />loop

If all you are doing is converting the line breaks to "<br />", you might try something like this:

text = Replace(text, "\n", "<br />");

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...