다음은 내 코드입니다. 내 웹 사이트에서 클래스를 사용했습니다. 그러나 '잘못된 구문이 근처에 있습니다', '...'라는 오류 메시지가 나타납니다.','근처에 구문이 잘못되었습니다. 업데이트 쿼리를 사용하는 중
protected void btnadd_Click(object sender, EventArgs e)
{
s1 = "Update tckt_tbl Set class='" + ddlclass.Text + "',dist=" + lbldist.Text + ",no_of_adults=" + ddladults.Text + ",no_of_senior=" + ddlsenior.Text + ",n1='" + txtn1.Text + "',";
s1 += "n2='" + txtn2.Text + "',n3='" + txtn3.Text + "',n4='" + txtn4.Text + "',n5='" + txtn5.Text + "',n6='" + txtn6.Text + "',";
s1 += "ag1=" + txtag1.Text + ",ag2=" + txtag2.Text + ",ag3=" + txtag3.Text + ",ag4=" + txtag4.Text + ",ag5=" + txtag5.Text + ",ag6=" + txtag6.Text + ",";
s1 += "gen1='" + txtgen1.Text + "',gen2='" + txtgen2.Text + "',gen3='" + txtgen3.Text + "',gen4='" + txtgen4.Text + "',gen5='" + txtgen5.Text + "',gen6='" + txtgen6.Text + "',";
s1 += "cn1='" + txtchn1.Text + "',cn2='" + txtchn2.Text + "',cag1=" + txtcag1.Text + ",cag2=" + txtcag2.Text + ",cgen1='" + txtcgen1.Text + "',cgen2='" + txtcgen2.Text + "' Where userid=" + Session["suser"].ToString() + "";
con.ExecQuery(s1);
Response.Redirect("tcktbook_itckt.aspx");
}
[SqlParameter] (http://msdn.microsoft.com/en-us/library)를 사용하십시오. /system.data.sqlclient.sqlparameter.aspx)이 옵션을 선택하면 [SQL Injection] (http://en.wikipedia.org/wiki/SQL_injection)에서 저장되지만 ** 쿼리가 더 읽기 쉽습니다 **. – Habib
디버거를 사용하고 s1에 어떤 값이 오는지 확인하십시오. –