Plz help how to optimise this code so that it will use less server resourses
and is it using so huch server resourses that my serving application pool is requesting recycle?? is it possible that this code will use more than 500mb of virtual memeory
try
{
int flg = 0;
SqlConnection cn = new SqlConnection("Data Source=servername;Initial Catalog=enefinde_memb;Persist Security Info=True;User ID=enefinde_admin;Password=abc");
String sql = "select email from regmember where email='" + txtEmail.Text + "'";
cn.Open();
SqlCommand cmd = new SqlCommand(sql, cn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
lblExists.Text="User name already exist Please Try Another One";
flg = 0;
}
else
{
flg = 1;
}
dr.Close();
if (flg == 1)
{
sql = "insert into regmember(enename,email,password,keyquestion,answer,address,city,state,country,perphone,mobile,cname,activity,yearofstarting,noofemp,location,website,phone)values('" + txtFname.Text + " " + txtMname.Text + " " + txtLname.Text + "','" + txtEmail.Text + "','" + txtPass.Text + "','" + ddlQuestion.Text + "','" + txtAns.Text + "','" + txtAdd.Text + "','" + txtCity.Text + "','" + txtState.Text + "','" + ddlCountry.Text + "','" + txtPerphone.Text + "','" + txtMob.Text + "','" + txtCname.Text + "','" + ddlAct.Text + "','" + txtStart.Text + "','" + ddlNoemp.Text + "','" + ddlCcountry.Text + " " + txtCstate.Text + " " + txtCcity.Text + "','" + txtWebsite.Text + "','" + txtPhone.Text + "' )";
cmd.CommandText = sql;
cmd.Connection = cn;
int i = cmd.ExecuteNonQuery();
if (i > 0)
//Response.Write("Record Inserted");
Response.Redirect("~/html/thankyou.html");
else
Response.Write("Not Inserted");
}
cn.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}