I am new to VS 2012 and need to use it with SQL Server. I need to get data from a table in SQL Server 2012 with 500 rows and 15 columns and process the data in it and update another table. All this has to be done in 100 ms.
I tried traditional method with SQL query filling a dataset and then access the table, rows and item array in each row. It is taking seconds to execute and the time worsening.
Should I use LINQ or another solution?
try
{
connection1.Open();
adapter_alarms = new SqlDataAdapter(sql_alarms, connection1);
adapter_alarms.Fill(ds_alarms);
connection1.Close();
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
if (ds_alarms.Tables[0].Rows.Count != 0)
{
for (int i = 0; i < ds_alarms.Tables[0].Rows.Count; i++)
{
if (bool.Parse(ds_alarms.Tables[0].Rows[i].ItemArray[7].ToString()) == true)
if (engValues[index] < float.Parse(ds_alarms.Tables[0].Rows[i].ItemArray[3].ToString()))
{
string sql_Al = "INSERT INTO [MCRCDA].[dbo].[Alarms]([DateTime],[TagName],[AlarmType],[Value],[Units],[Address]) VALUES("+"'10/08/2015'" +", '"+ds_alarms.Tables[0].Rows[i].ItemArray[0].ToString().Trim()+"','Lo',10.4,'C','1.1.1')";
try
{
connection1.Open();
adapter_alarms = new SqlDataAdapter(sql_Al, connection1);
adapter_alarms.Fill(ds_alarms);
connection1.Close();
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}//MessageBox.Show("Lo");
}
}
}
sql_alarms
\$\endgroup\$