|
这是代码:
protected void Button1_Click(object sender, EventArgs e)
{
int i = 0;
string sqlstr = "delete form news (ntitle,ncontent,pubdate) values ('" + txt_title.Text + "','" + txt_text.Text + "','" + DateTime.Now + "')";
SqlConnection mycon = new SqlConnection();
mycon.ConnectionString = ConfigurationManager.ConnectionStrings["sweetConnectionString"].ToString();
SqlCommand mycom = new SqlCommand(sqlstr, mycon);
try
{
mycon.Open();
i = mycom.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
mycon.Close();
}
if (i > 0)
{
Response.Write("<script>alert('删除成功!')</script>");
}
}
错误是
news' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 'news' 附近有语法错误。
源错误:
行 59: catch (Exception ex)
行 60: {
行 61: throw (ex);
行 62: }
行 63: finally
|
|