S
Sudip_inn
Guest
i call my SP with ExecuteReader but it taken long time to get call my SP. from my SP i insert few test data in table and when i call my SP with ExecuteReader then i repeatedly issue a select my from table from SSMS but got no data.
just very confused why it is taking long time. i am using sql server 2017
see my code which is very simple
try
{
// Calling store proc to insert data into db
DataTable table = new DataTable();
SqlDataReader reader = null;
using (SqlConnection con = new SqlConnection(sConnectionString))
{
using (SqlCommand cmd = new SqlCommand("[dbo].[USP_InsertDataFromXML1]", con))
{
cmd.CommandTimeout = 3600; // Setting command timeout to 2 minutes
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Ticker", SqlDbType.VarChar).Value = Ticker;
cmd.Parameters.Add("@PCName", SqlDbType.VarChar).Value = System.Environment.MachineName;
con.Open();
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
}
}
//}
}
}
}
catch (Exception ex)
{
//MessageBox.Show("Error " + ex.Message.ToString());
}
finally
{
}
from this link i found a hint which i used but no luck still
con.Open();
using (SqlCommand comm = new SqlCommand("SET ARITHABORT ON", con))
{
comm.ExecuteNonQuery();
}
can you please suggest some way to call my SP very fast. what else i need to add or change in my code?
what is SET ARITHABORT ON means ?
please guide
Continue reading...
just very confused why it is taking long time. i am using sql server 2017
see my code which is very simple
try
{
// Calling store proc to insert data into db
DataTable table = new DataTable();
SqlDataReader reader = null;
using (SqlConnection con = new SqlConnection(sConnectionString))
{
using (SqlCommand cmd = new SqlCommand("[dbo].[USP_InsertDataFromXML1]", con))
{
cmd.CommandTimeout = 3600; // Setting command timeout to 2 minutes
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Ticker", SqlDbType.VarChar).Value = Ticker;
cmd.Parameters.Add("@PCName", SqlDbType.VarChar).Value = System.Environment.MachineName;
con.Open();
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
}
}
//}
}
}
}
catch (Exception ex)
{
//MessageBox.Show("Error " + ex.Message.ToString());
}
finally
{
}
from this link i found a hint which i used but no luck still
con.Open();
using (SqlCommand comm = new SqlCommand("SET ARITHABORT ON", con))
{
comm.ExecuteNonQuery();
}
can you please suggest some way to call my SP very fast. what else i need to add or change in my code?
what is SET ARITHABORT ON means ?
please guide
Continue reading...