using System.Data.SqlClient;
using System.Data.Sql;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=GAGAN-PC\SQLEXPRESS;Initial Catalog=update_test;Integrated Security=True");
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void delete_button_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("delete from update_delete where id like'"+TextBox1.Text+"'",con);
cmd.ExecuteNonQuery();
Response.Write("Control reached.");
con.Close();
Response.Write("Data successfully deleted.");
}
protected void update_button_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("update update_delete set password ='"+TextBox3.Text+"' where id like'"+TextBox2+"'", con);
cmd.ExecuteNonQuery();
Response.Write("Control reached.");
con.Close();
Response.Write("Data successfully Updated.");
}
}
ASP.NET 웹 응용 프로그램에서 작동하지 않습니다. SQL Server를 데이터베이스로 사용하고 update_delete
은 3 열 id,sname,password
이 있고 id와 관련하여 암호를 업데이트하려고하는 테이블입니다.업데이트 쿼리 내가 업데이트 쿼리를 구현하기 위해 노력하고 있지만, 약간의 문제가 거기에있다
문제는 내가 업데이트 버튼 컨트롤을 클릭하면 cmd.ExecuteNonQuery();
에 도달하면 오류가 표시됩니다. 업데이트는 일어나지 않습니다. 내가 어떻게해야하지? 제발 제발 나를 도와주세요. 미리 감사드립니다. :) :)
이렇게 많은'IDisposable' 객체. ( –
) 많은 쿼리, 너무 적은 매개 변수 - 너무 많은 ** SQL Injection ** 위험! –
잘못된, marc_s INT와 같은 숫자 데이터 유형에 LIKE OPERATOR를 사용할 수 있습니다. 하지만 예상대로 작동합니다. – laylarenee