这是我的插入声明的代码,但是在插入声明
时,aspx抛出错误是错误的所有代码块都正常运行,但我不明白代码如何处理插入数据这里是包含所有参数及其各自值的代码,代码抛出错误的查询执行
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.OleDb;
public partial class userLogin : System.Web.UI.Page
{
OleDbConnection cn = new OleDbConnection();
protected void Page_Load(object sender, EventArgs e)
{
cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\abhishek\\Downloads\\startbootstrap-sb-admin-gh-pages\\startbootstrap-sb-admin-gh-pages\\crm1.mdb");
}
//Provider=Microsoft.Jet.OLEDB.4.0;Data Source="E:\study\ty bca\Wheeler Dealer\App_Data\Register.mdb";Persist Security Info=True
protected void Button1_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
OleDbParameter p1, p2, p3, p4, p5;
p1 = new OleDbParameter();
p2 = new OleDbParameter();
p3 = new OleDbParameter();
p4 = new OleDbParameter();
p5 = new OleDbParameter();
cn.Open();
p1.ParameterName = "O_Name";
p1.Value = TextBox1.Text;
p2.ParameterName = "O_Add";
p2.Value = TextBox2.Text;
p3.ParameterName = "E_Mail";
p3.Value = TextBox3.Text;
p4.ParameterName = "Mob";
p4.Value = Double.Parse(TextBox4.Text);
p5.ParameterName = "password";
p5.Value = TextBox5.Text;
cmd.CommandText = "insert into user values (@O_Name,@O_Add,@E_Mail,@Mob,@password)";
cmd.Connection = cn;
cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
cmd.Parameters.Add(p3);
cmd.Parameters.Add(p4);
cmd.Parameters.Add(p5);
cmd.ExecuteNonQuery();
cn.Close();
}
}