﻿<?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 » Business Objects and Data Access (How do I?)  » When I save I get an error that says</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 15 Sep 2026 02:43:13 GMT</lastBuildDate><ttl>20</ttl><item><title>When I save I get an error that says</title><link>http://forum.strataframe.net/FindPost24874.aspx</link><description>And I really do not understand why. I set the BO's AllowNullValuesOnNewRow property to true because From the documentation (even though it sounds a little backwards :P):&lt;/P&gt;&lt;P&gt;When True, the NewRow() function will automatically initialze the row to prevent any DBNull values from occurring&lt;/P&gt;&lt;P&gt;In the BO mapper, I also customized the field to return alternate on null - is_primary is a boolean field, so I set the alternate to false.&lt;/P&gt;&lt;P&gt;So I am more than a little mystified that I am getting this error - can someone please help me find a solution?&lt;/P&gt;&lt;P&gt;DataLayerSavingException&lt;BR&gt;&amp;nbsp; Cannot insert the value NULL into column 'is_primary', table 'TGIF.dbo.Contact'; column does not allow nulls. INSERT fails.&lt;BR&gt;The statement has been terminated.&lt;BR&gt;SqlException&lt;BR&gt;&amp;nbsp; Cannot insert the value NULL into column 'is_primary', table 'TGIF.dbo.Contact'; column does not allow nulls. INSERT fails.&lt;BR&gt;The statement has been terminated.&lt;/P&gt;&lt;P&gt;Source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : MicroFour StrataFrame Business&lt;/P&gt;&lt;P&gt;Stack Trace: &lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlDataReader.get_MetaData()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteReader(DbCommand Command, Boolean IsTransactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DataLayer.Save(DataTable TableToSave, Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Business.BusinessLayer.Save()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at TGIF.Forms.Contact.cmdOK_Click(Object sender, EventArgs e) in F:\TGIF\Forms\Contact.cs:line 109&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;BR&gt;</description><pubDate>Tue, 06 Oct 2009 23:59:45 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I save I get an error that says</title><link>http://forum.strataframe.net/FindPost24884.aspx</link><description>A better place would be using the SetDefaultValues event.  I typically handle it in the BO and then you don't have to worry about it.</description><pubDate>Tue, 06 Oct 2009 23:59:45 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: When I save I get an error that says</title><link>http://forum.strataframe.net/FindPost24878.aspx</link><description>I tried leaving it set to false - same problem. So, I did this in the BO's BeforeSave method and that took care of the problem:&lt;/P&gt;&lt;P&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// when all else fails, try a bigger hammer&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// kept getting a "column does not accept null values" error&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// on save&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; (chkis_primary.Checked == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; boContact.is_primary = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 06 Oct 2009 17:32:34 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I save I get an error that says</title><link>http://forum.strataframe.net/FindPost24877.aspx</link><description>And as I reread the docs, they appear to be backwards.  I.e. based on docs true would initialize, but in source, its obviously false that causes the initialization...&lt;br&gt;
&lt;br&gt;
[codesnippet]If Not _AllowNullValuesOnNewRow Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- initialization code&lt;br&gt;
End If[/codesnippet]</description><pubDate>Tue, 06 Oct 2009 15:00:27 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: When I save I get an error that says</title><link>http://forum.strataframe.net/FindPost24876.aspx</link><description>It appears that if you want the BO to initialize your columns with default data based on the data type, you need to set the AllowNullValuesOnNewRow property to [b]false[/b].  If it is true, it allows NULLs in the current data table. If false, then it does the initialization. (checked source to figure out what was up).</description><pubDate>Tue, 06 Oct 2009 14:57:15 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>