How do you insert data into MSSQL - TechRepublic
Question
May 8, 2009 at 07:43 AM
johnsaraka

How do you insert data into MSSQL

by johnsaraka . Updated 17 years, 2 months ago

I am stuck on the line when I am trying to insert the records into the db.
Thanks. John

classTPL TPL = new classTPL(_DatabaseConnection);
if (!File.Exists(this.tbSelectFile.Text))
throw new Exception(“Input file not found!”);

if (!File.Exists(@”e:\TPLImport.xml”))
throw new Exception(“Mapping file not found.”);

// we got the file here so lets open it and start the import process
//Create a clsKEAImport
if (checkBoxRecreate.Checked)
{
TPL.Recreate();
}

DateTime importtime = DateTime.Now;
TPL.Initialize();
TPL.importTime = importtime;

List> records = ParseFile(this.tbSelectFile.Text);
// Ok now lets insert that thing into the database

foreach (List record in records)
{

foreach (Field field in record)
{
TPL.Insert();

}

lblStatus.Text = “Records Inserted = ” + records.ToString();
lblStatus.Refresh();
Application.DoEvents();
}

This discussion is locked

All Comments