数据插入不了,请各位大大帮帮忙!
namespace QYApplication1
{
public partial class AddClass : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) {
string sql = "insert into class_qy(Class_name) values('" + Textbox1.Text.Trim() + "')";
string con = ConfigurationManager.ConnectionStrings["SiteMapConnectionString"].ToString();
SqlConnection sqlConn = new SqlConnection(con);
SqlCommand sqlCmd = new SqlCommand(sql, sqlConn);
sqlCmd.Connection.Open();
sqlCmd.ExecuteNonQuery();
sqlCmd.Connection.Close();
}
}
页面点击按钮后,数据库中还是增加不了数据,但是执行时没有显示错误信息,请各位大大帮帮忙。}------解决方案--------------------单步调试一下,看看有没有错误。
------解决方案--------------------正解
<asp:Button ID="Button1" runat="server" Text="提交分类" onclick="Button1_Click" />
应该是OnClick