Terry Bottorff (01/31/2009)
Cannot insert the value NULL into column 'swst_pk', table 'ProRodeo.dbo.SWStocks'; column does not allow nulls. INSERT fails.
The statement has been terminated.
I get the above error when I try the following code?
SwStockBO1.NewRow()
SwStockBO1.swst_pk = 1
SwStockBO1.stock = 1000
' Save New RecordIf SwStockBO1.Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success ThenMsgBox(
"Save New Record Failed")End IfI'm a newbie so what am I missing? TIA.
Is your data in SQL Server? Is swst_pk defined as a primary key? Why don't you just set it up as an identity column and use code like this:
SwStockBO1.Add();
SwStockBO1.stock = 1000;
Try
{
SwStockBO1.Save();
}
Catch ( Exception loErr )
{
MicroFour.StrataFrame.Messaging.
MessageForm.ShowMessage("Trinity Contact Management", loErr.Message.ToString(), "00000", MessageFunction.OK, MessagingIcon.Information, MessagingSounds.None);}
If your primary key is an identity, you will not have these problems because SQL Server automagically takes care of generating it for you.