PDA

View Full Version : سوال: مشکل در استفاده از response در داخل try



mehrdad85
چهارشنبه 01 تیر 1390, 08:49 صبح
سلام
دوستان یک دنیا ممنونتون میشم بهم بگید این کد کجاش مشکل داره؟
برای اجرا شدن هر قسمت یه alert گذاشتم که ببینم کجا اجرا میشه اما هیچ کدوم ظاهرا اجرا نمیشن
مگه همچین چیزی ممکنه؟



protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrin gs["sampleConnectionString"].ToString());
scon.Open();
SqlCommand scom1 = new SqlCommand("SELECT COUNT(*) FROM [table1] WHERE(field1='" + Label278.Text + "')", scon);

scom1.ExecuteNonQuery();
int num = (int)scom1.ExecuteScalar();
if (num == 0)
{
try
{
Insertsampl1SDS1.Insert();
InsertsampleSDS2.Insert();
Response.Write("<script> alert('sth')</script>");
Response.Redirect("~/Default.aspx");
}
catch (Exception e)
{
Response.Write("<script> alert('sth')</script>");
}


}else
{
Response.Write("<script> alert('sth')</script>");
}





مرسی