Hello,
I'm having some trouble with SQL CE.
The below code *should* insert a record into the 'maps' table. (table adapters all set up)
sometimes it says cannot insert as breaching primary key constraint, which is fine, but it otherwise fails with cannot insert NULL into iMapId. I have checked and txtNumber.Text.ToString is not null, and I've even tried explicitly setting newMap["iMapId"] equal to some integer and it still complains that it's null.
try
{
DataRow newMap = mapappdbDataSet.maps.NewRow();
newMap["iRegionId"] = Convert.ToInt16(cmbRegion.SelectedValue);
newMap["vMapName"] = txtMapNAme.Text.ToString();
newMap["iMapId"] = txtNumber.Text.ToString();
mapappdbDataSet.maps.Rows.Add(newMap);
mapsTableAdapter.Update(newMap);
mapappdbDataSet.AcceptChanges();
this.Close();
}
catch (Exception excp)
{
MessageBox.Show("That didnt work. Heres the message: " + excp.Message.ToString());
}
Any ideas at all?
Thanks