yklxmas Posted November 10, 2006 Share Posted November 10, 2006 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 More sharing options...
jesh Posted November 10, 2006 Share Posted November 10, 2006 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 More sharing options...
yklxmas Posted November 10, 2006 Author Share Posted November 10, 2006 Thanks. But that's quite what I would like.I would like to insert them all the contents of one file in one field. Any help? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2006 Share Posted November 10, 2006 Show your code, and tell what you want to do that the code is not doing. Link to comment Share on other sites More sharing options...
yklxmas Posted November 14, 2006 Author Share Posted November 14, 2006 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 More sharing options...
jesh Posted November 14, 2006 Share Posted November 14, 2006 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 More sharing options...
justsomeguy Posted November 14, 2006 Share Posted November 14, 2006 I think that this would be more appropriate:textline = textline & vbcrlf & f.ReadLine Link to comment Share on other sites More sharing options...
yklxmas Posted November 16, 2006 Author Share Posted November 16, 2006 I think that this would be more appropriate:textline = textline & vbcrlf & f.ReadLineI googled for vbcrlf and found this link. http://www.dmxzone.com/ShowDetail.asp?NewsId=1721. I think i'll give this a go.Thanks everyone. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now