insert file line by line to database code charp Raw

code
https://gist.github.com/zerowapo/8c80b9cef3fb2fab9e349608ca3443cb


int counter = 1;
string line;
string t="";
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(@"C:\Users\HP\Downloads\index.txt");
while ((line = file.ReadLine()) != null)
{
// MessageBox.Show(counter + 1 + ":" + line + "\n");
t = "Insert Into word_arabic2 (id,Name) values ('"+counter+"','"+line+"');";
string path=@"C:\Users\HP\Documents\visual studio 2012\Projects\insert_line_DB\insert_line_DB\Db_word.txt";
using (System.IO.StreamWriter ts =
new System.IO.StreamWriter(path, true))
{
ts.WriteLine(t);
ts.Close();
//File.WriteAllText(path, String.Empty);
}
counter++;
}
file.Close();
richTextBox1.Text = t;

شارك الموضوع

إقرأ أيضًا