我基本上想将一些值存储到数据库中。
我不断收到"Number of query values and destination fields are not the same."
指向“ dr = cmd.ExecuteReader();
有人可以帮助我吗?:)
我对整个事情有点陌生,真的不知道发生了什么。
贝娄是正在使用的代码。
public partial class Registeration_experiment : System.Web.UI.Page
{
static OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\New folder\Project 1.0\WebSite1\New Microsoft Office Access 2007 Database.accdb");
OleDbDataAdapter ada = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "insert into Registeration_Test (Name1, address, emailaddress)" +
"values (?, ?, ?)";
con.Open();
cmd = new OleDbCommand(str, con);
cmd.Parameters.AddWithValue("@p1", TextBox1.Text);
cmd.Parameters.AddWithValue("@p2", TextBox2.Text);
cmd.Parameters.AddWithValue("@p4", TextBox4.Text);
cmd.ExecuteNonQuery();
}
}
谢谢 :)