Can not Insert Null Value When I save


Author
Message
Terry Bottorff
Terry Bottorff
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 448, Visits: 12K
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 Record

If SwStockBO1.Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

MsgBox("Save New Record Failed")

End If

I'm a newbie so what am I missing? TIA.

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Terry,

Just a comment re 'not wanting the PK to get bigger and bigger'. I presume you a using SQL Server in which case you can be assured it can handle the load unless you have an enormous insert rate, e.g. 1 per second for 10 years would only get your Identity column up to about the 300 million mark - 'easy as' for SQL Server.

Given that the PK is being 'reset' so regularly I can't imagine it has any interest to the user but, if it has, I would recommend adding another column for that use and simply let SQL take care of the PK.

Cheers, Peter

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Terry, the reason that you are getting the error is answered in Edhy's post.  You will have to set the BO properties on the BO to allow the primary key field to be updated.  This is the same approach that you would take if you were using GUIDs.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search