-1
나는 C#을 초보자예외가 system.data.dll에서 발생하지만
내가 오류 "의 예외를 얻고에게있어 사용자 코드의 혼란에서 처리되지 않은 'System.Data.SqlClient.SqlException'System.Data.dll에서 발생했지만 사용자 코드에서 처리되지 않았습니다. "응용 프로그램이 실행 중일 때 제출 단추를 누를 때
이 코드는 내 코드입니다. 오류
public partial class About : Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into Table values('" + txtName.Text + "','" + txtPrice.Text + "','" + txtQuan.Text + "','" + txtURL.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Visible = true;
Label1.Text = "Your Data Stored Succesfully!";
txtName.Text = "";
txtPrice.Text = "";
txtQuan.Text = "";
txtURL.Text = "";
}
두 번째로 버튼을 클릭하면 어떻게됩니까? 연결을 닫은 후 버튼을 처음 클릭했을 때 다시 연결하려고 시도했을 수 있습니다. –
아니요 한 번만 버튼을 클릭하면 단 한 번의 클릭으로 오류가 발생합니다. – James
cmd.ExecuteNonQuery에서 몇 가지 중단 점을 설정하십시오. 또한 try {} catch {}를 중심으로 그 코드를 감추고 호기심을 불러 일으 킵니다. 표가 아닙니다. 너의 테이블 이름이 ...? 실제 테이블 이름은 무엇입니까? 매개 변수화 된 쿼리를 활용하기 위해 Insert 쿼리를 변경하십시오 ... – MethodMan