菜鸟 求教 using System; using System.Collections; 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 Scripts_Default : System.Web.UI.Page { protected void Button3_Click(object sender, EventArgs e) { string Name = TextBox1.Text.Trim(); string Password = TextBox2.Text.Trim();
string sql = "insert into [yl] values('" + 3 + "','" + Name + "','"+Password+"')"; SqlCommand cmd = new SqlCommand(sql, conn);
int i = cmd.ExecuteNonQuery(); if (i> 0) { Response.Write("<script>alert('注册成功');</script>"); } else { Response.Write("<script>alert('注册不成功,请检查输入信息');</script>"); } conn.Close();
} }
我这个注册页面为什么 不能使数据库添加数据呢
------解决方案-------------------- string sql = "insert into [yl] values('" + 3 + "','" + Name + "','"+Password+"')";