我有一個數據庫表,所有列允許空值用於測試目的。在我所有的列之間,我有int,varchar或bit數據類型。當我嘗試提交表單,我得到了以下錯誤消息:幫助LINQ到SQL插入錯誤
Value was either too large or too small for an Int32.
下面是代碼:
using (storeDataContext db = new storeDataContext())
{
db.Dealerssses.InsertOnSubmit(new Dealersss
{
AppFName = txtFName.Text,
AppLName = txtLName.Text,
AppTitle = ddlTitles.SelectedItem.Text,
AppPhone = Convert.ToInt32(txtPhone.Text),
AppEmail = txtEmail.Text,
AppAddress = txtAddress.Text,
AppCity = txtCity.Text,
AppState = txtState.Text,
AppZip = Convert.ToInt32(txtZip.Text),
BusName = txtBusName.Text,
BusCA = Convert.ToInt32(txtBusResale.Text),
BusContact = txtBusContact.Text,
BusDBA = txtDBA.Text,
BusEIN = Convert.ToInt32(txtBusEIN.Text),
BusEmail = txtBusEmail.Text,
BusFax = Convert.ToInt32(txtBusFax.Text),
BusMonth = ddlMonthStart.SelectedItem.Text,
BusNumEmployees = Convert.ToInt32(txtBusEmployees.Text),
BusPhone = Convert.ToInt32(txtBusPhone.Text),
BusYear = int.Parse(txtYearStart.Text),
Active = false
});
db.SubmitChanges();
};
您是否看過錯誤? – SLaks 2011-01-21 03:35:42
@slaks,表單中發佈的值在1到15位之間,因此int32的值不可能太大。 – 2011-01-21 03:37:16