View Single Post
  #1 (permalink)  
Old March 12th, 2009, 01:51 AM
RushNP774 RushNP774 is offline
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Question Filling SQL database table from a txt file - How do I do it?

I accidentally overwrote all the data in a column of one of my tables with a bad SQL command, and now want to rebuild the table with data from a text file. The table is just an Id field (auto generated primary key), a field for "Name", and one for "Category". At runtime, I'd simply like to take each value in my text file, and insert it into the "Name" field of my table.

I've read a bunch of tutorials on using the System.IO.StreamReader object to read files, but can never get anything to work. The project can't find my file, or I get other errors that I can't decode even after I copy the code verbatim. Here are a couple I looked at:

http://aspnet.4guysfromrolla.com/articles/051802-1.aspx
http://msdn.microsoft.com/en-us/libr...eamreader.aspx

It's one small text file with a value on each line, and I just want to create a table record for each. Any help would be GREATLY appreciated!