﻿<?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 / Issues  / Unexpected problem inserting / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>forum@strataframe.net</webMaster><lastBuildDate>Fri, 21 Nov 2008 14:16:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>Daniel,&lt;P&gt;The problem was actually very simple.  To resolve your error, set the PrimaryKeyIsAutoIncremented property on the EntityProgram business object to False.  Since your database does not automatically increment the PK the value is NULL when it is attempting return the new PK value which is causing your problem.&lt;/P&gt;&lt;P&gt;In your case, set the PrimaryKeyIsAutoIncremented to False in the designer of the business object since you will never want this particular BO to pull an auto-incremented PK back from the server on a new row.  Keep this in mind for your other BOs as well.</description><pubDate>Tue, 14 Mar 2006 16:02:22 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>I don't have enough info to give you an answer.  I need to you do two things.  First see if there is an inner exception.  Also, what could really help is a screen shot of the contents of the CurrentDataTable.  To get this do the following:&lt;/P&gt;&lt;P&gt;1. Put a breakpoint on the Save() method.&lt;BR&gt;2. In the watch window put YourBOInstance.CurrentDataTable&lt;BR&gt;3. Click the magnifying glass to the right of the value.  This will bring up a browse window&lt;BR&gt;and show the contents.  &lt;/P&gt;&lt;P&gt;If you can give me a screen shot it would help.  You will probably have to email the image since it will be shrunk in the forum update.</description><pubDate>Mon, 13 Mar 2006 14:54:08 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>Both fields in the BO contained valid strings at the time the Save() error occurred.</description><pubDate>Mon, 13 Mar 2006 13:17:09 GMT</pubDate><dc:creator>Daniel Essin</dc:creator></item><item><title>RE: Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>By default a business object does not allow NULL values.  To add NULL value support you need to do two things.&lt;/P&gt;&lt;P&gt;1. Set the AlloNullValuesOnNewRow to True on the BO itself.&lt;BR&gt;2. Next, in the BO Mapper, you can specify NULL support.  There are two options, Generic Nullable and Return Alternate Value on NULL.  This does not affect the data on the server, but adds support to the strong-typed properties so the controls can interact without failing.  The most common option is Return Alternate on NULL.  When using this method, simply put the desired return value on in the text spacea below.  If you want to return an empty string, simply put the following value in the provided field: ""&lt;/P&gt;&lt;P&gt;This should resolve this error.</description><pubDate>Sun, 12 Mar 2006 23:09:11 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>You probably need the stack trace:&lt;br&gt;"   at MicroFour.StrataFrame.Business.BusinessLayer.SaveBase(Boolean Transactional, String TransactionKey)\r   at MicroFour.StrataFrame.Business.BusinessLayer.Save()\r   at DSM.FormSelectEntity.buttonEnroll_Click(Object sender, EventArgs e) in E:\\_work.NET\\DSM\\DSM\\FormSelectEntity.cs:line 139\r   at System.Windows.Forms.Control.OnClick(EventArgs e)\r   at System.Windows.Forms.Button.OnClick(EventArgs e)\r   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\r   at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)\r   at System.Windows.Forms.Control.WndProc(Message&amp; m)\r   at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)\r   at System.Windows.Forms.Button.WndProc(Message&amp; m)\r   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)\r   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)\r   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"</description><pubDate>Sun, 12 Mar 2006 23:01:54 GMT</pubDate><dc:creator>Daniel Essin</dc:creator></item><item><title>Unexpected problem inserting</title><link>http://forum.strataframe.net/Topic620-10-1.aspx</link><description>This is the code:&lt;br&gt;                _EntityProgram.Add();&lt;br&gt;                _EntityProgram.MRN = _Entity.MRN;&lt;br&gt;                _EntityProgram.EnrolledProgram = comboPrograms.Text;&lt;br&gt;                _EntityProgram.Save();&lt;br&gt;&lt;br&gt;_EntityProgram is an instance of a BO&lt;br&gt;&lt;br&gt;This is the DDL for the table behind the BO:&lt;br&gt;CREATE TABLE [dbo].[EntityProgram] (&lt;br&gt;	[MRN] [varchar] (36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,&lt;br&gt;	[EnrolledProgram] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL &lt;br&gt;) ON [PRIMARY]&lt;br&gt;GO&lt;br&gt;&lt;br&gt;ALTER TABLE [dbo].[EntityProgram] WITH NOCHECK ADD &lt;br&gt;	CONSTRAINT [PK_EntityProgram] PRIMARY KEY  CLUSTERED &lt;br&gt;	(&lt;br&gt;		[MRN],&lt;br&gt;		[EnrolledProgram]&lt;br&gt;	)  ON [PRIMARY] &lt;br&gt;GO&lt;br&gt;&lt;br&gt;It's complaining about converting varchar to numeric but both fields are varchar and both are part of the PK.&lt;br&gt;&lt;br&gt;This is the Error:&lt;br&gt;Cannot insert the value NULL into column 'EnrolledProgram', table 'CRM.dbo.EntityProgram'; column does not allow nulls. INSERT fails.&lt;br&gt;Error converting data type varchar to numeric.</description><pubDate>Sun, 12 Mar 2006 22:38:24 GMT</pubDate><dc:creator>Daniel Essin</dc:creator></item></channel></rss>