System.Data.dll中出现“System.Data.OleDb.OleDbException”类型的异常,但未在用户代码中处理其他信息:溢出

时间:2016-02-06 03:09:42

标签: c# asp.net

protected void btnSubmitForm_Click(object sender, EventArgs e)
{
    Page.Validate();
    if (Page.IsValid)
    {

        connParam = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Validation.accdb") + ";Persist Security Info=False;";
        OleDbConnection con = new OleDbConnection(connParam);
        con.Open();
        OleDbCommand cmd = new OleDbCommand("INSERT INTO tblClients (Firstname,Lastname, Phone,StreetAddress,City,Country, ZipCode) VALUES (@fname,@lname,@phone,@saddress,@city,@country, @zipcode)", con);
        cmd.Parameters.AddWithValue("@fname", fName.Text);
        cmd.Parameters.AddWithValue("@lname", lName.Text);
        cmd.Parameters.AddWithValue("@phone", phone.Text);
        cmd.Parameters.AddWithValue("@saddress", address.Text);
        cmd.Parameters.AddWithValue("@city", city.Text);
        cmd.Parameters.AddWithValue("@country", country.Text);
        cmd.Parameters.AddWithValue("@zipcode", zipcode.Text);
        cmd.ExecuteNonQuery();
        con.Close();
        Response.Redirect("Display.aspx");
    }
}

我的插入有效但当我多次按下提交按钮时(我有验证器来测试我的文本框是否输入正确或缺少文本)'cmd.ExecuteNonQuery();'给出异常错误。我不知道为什么,我是新手,因此任何提示都会有所帮助,谢谢。

0 个答案:

没有答案