哪为 高手帮我看看下面代码怎么错了 老是删除失败!
using System;using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string sql = "deletefrom book where k_id='" +Convert.ToInt32( this.TextBox1.Text)
+ "'and name='"
+ this.TextBox2.Text.ToString() + "'";
if (DB.EN(sql)>=1)
{
Response.Write("删除成功");
}
else
{
Response.Write("删除失败");
}
}
}
DB类
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
/// <summary>
///DB 的摘要说明
/// </summary>
public class DB
{
public DB()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public static int EN(string sqlstr)
{
int a=0;
string str ="Data Source=7164BD0790E2444\\LIU;Initial Catalog=text;Integrated Security=True";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand(sqlstr, con);
try
{
a = cmd.ExecuteNonQuery();
}
catch (Exception e)
{
}
finally
{
con.Close();
}
return a;