﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Can not Insert Null Value When I save</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 07:38:40 GMT</lastBuildDate><ttl>20</ttl><item><title>Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21749.aspx</link><description>Cannot insert the value NULL into column 'swst_pk', table 'ProRodeo.dbo.SWStocks'; column does not allow nulls. INSERT fails.&lt;BR&gt;The statement has been terminated.&lt;P&gt;I get the above error when I try the following code?&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;SwStockBO1.NewRow()&lt;/P&gt;&lt;P&gt;SwStockBO1.swst_pk = 1&lt;/P&gt;&lt;P&gt;SwStockBO1.stock = 1000&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;' Save New Record&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; SwStockBO1.Save() &amp;lt;&amp;gt; MicroFour.StrataFrame.Data.SaveUndoResult.Success &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;MsgBox(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Save New Record Failed"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;I'm a newbie so what am I missing? TIA.</description><pubDate>Mon, 02 Feb 2009 10:06:11 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21770.aspx</link><description>That was it. Thank you very very much. The help here is excellant.:)</description><pubDate>Mon, 02 Feb 2009 10:06:11 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21766.aspx</link><description>Terry, the reason that you are getting the error is answered in Edhy's post.&amp;nbsp; You will have to set the BO properties on the BO to allow the primary key field to be updated.&amp;nbsp; This is the same approach that you would take if you were using GUIDs.</description><pubDate>Mon, 02 Feb 2009 09:37:47 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21757.aspx</link><description>Hi Terry,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Sun, 01 Feb 2009 19:08:16 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21756.aspx</link><description>Hi Terry,&lt;/P&gt;&lt;P&gt;If you want to manage your own PK updates you have to set the following BO properties:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;PrimaryKeyIsAutoIncremented = False&lt;/LI&gt;&lt;LI&gt;PrimaryKeyIsUpdatable = True&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Then in the BO_SetDefaultValues() or somewhere else in your code update the PrimaryKey field value.</description><pubDate>Sun, 01 Feb 2009 18:06:34 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21755.aspx</link><description>&lt;IMG src="http://forum.strataframe.net/Uploads/Images/bb0e656f-3aa8-4ee2-8798-b999.png"&gt;&lt;/P&gt;&lt;P&gt;The same error that I reported previous.</description><pubDate>Sun, 01 Feb 2009 07:35:58 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21754.aspx</link><description>Yes swst_pk is my primary key. The reason I don't have it as an identity is because the table get's rewritten 3 times a day with completely new data and I did not want the primary key to get bigger and bigger and bigger even though that probably is not a good reason. I manage it with an array of the same numbers and the only thing that chages is the stock field.&lt;/P&gt;&lt;P&gt;Thank you for the error code I will try it and report back. Thanks again.</description><pubDate>Sun, 01 Feb 2009 07:21:34 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21751.aspx</link><description>[quote][b]Terry Bottorff (01/31/2009)[/b][hr]Cannot insert the value NULL into column 'swst_pk', table 'ProRodeo.dbo.SWStocks'; column does not allow nulls. INSERT fails.&lt;BR&gt;The statement has been terminated.&lt;P&gt;I get the above error when I try the following code?&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;SwStockBO1.NewRow()&lt;/P&gt;&lt;P&gt;SwStockBO1.swst_pk = 1&lt;/P&gt;&lt;P&gt;SwStockBO1.stock = 1000&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;' Save New Record&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; SwStockBO1.Save() &amp;lt;&amp;gt; MicroFour.StrataFrame.Data.SaveUndoResult.Success &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;MsgBox(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Save New Record Failed"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;I'm a newbie so what am I missing? TIA.[/quote]&lt;P&gt;Is your data in SQL Server? Is swst_pk&amp;nbsp;defined as a primary key? Why don't you just set it up as an identity column and use code like this:&lt;P&gt;SwStockBO1.Add();&lt;/P&gt;&lt;P&gt;SwStockBO1.stock = 1000;&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SwStockBO1.Save();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Catch ( Exception loErr )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;MicroFour.StrataFrame.Messaging.&lt;/FONT&gt;MessageForm&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.ShowMessage(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Trinity Contact Management"&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;, loErr.Message.ToString(), &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"00000"&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MessageFunction&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.OK, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MessagingIcon&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.Information, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MessagingSounds&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;.None);&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;If your primary key is an identity, you will not have these problems because SQL Server automagically takes care of generating it for you.</description><pubDate>Sat, 31 Jan 2009 14:59:05 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: Can not Insert Null Value When I save</title><link>http://forum.strataframe.net/FindPost21750.aspx</link><description>PS.&lt;/P&gt;&lt;P&gt;The table has only 2 fields. swst_pk, and stock. Both are integer and don't allow nulls.&lt;/P&gt;&lt;P&gt;I also tried playing with Return Alternate on Null in the BO Mapper but could not get that working. Also, played with AllowNullValueonNewRow in the properties using both True and False and did not get that to work either. My version of SF is 1.6.6.0</description><pubDate>Sat, 31 Jan 2009 14:31:36 GMT</pubDate><dc:creator>Terry Bottorff</dc:creator></item></channel></rss>