﻿<?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?)  » Maintennace Forms and PK queries</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 26 Sep 2026 00:12:22 GMT</lastBuildDate><ttl>20</ttl><item><title>Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22878.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;I have the following 2 queries:&lt;/P&gt;&lt;P&gt;1) I have a maintenance form with 2 bound textboxes, 1 textbox for a db field name (textBox1)&amp;nbsp;and the other for a friendly display name (textBox2). During New i would like the friendly name to be the mirror of the field name whilst the user is inputting the data. I have set. In the&amp;nbsp;Change event on textBox1&amp;nbsp;I set &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textBox2.Text = textBox.Text&lt;/P&gt;&lt;P&gt;When I run the app and attempt to create a new record, I enter a character into textBox1 the change event is invoked and the data is copied to textBox2 but then the character is obliterated. Any subsequent keypress results in a blank textBox1 and textBox2. I have noticed that there seems to be multiple calls to the change event when a single key is pressed.&amp;nbsp; Does anyone have an explanation for this?&lt;/P&gt;&lt;P&gt;2) When I update a new record I get the error "Cannot insert the value NULL into config_pk etc. I have the properties on the PrimaryKeyIsAtoIncremented= True and PrimaryKeyIsUpdateable= false. Is there another property that I should look out for?&lt;/P&gt;&lt;P&gt;many thanks</description><pubDate>Thu, 30 Apr 2009 08:42:55 GMT</pubDate><dc:creator>Ian Hammond</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22973.aspx</link><description>No problem, Ian.&amp;nbsp; Glad you got it figured out.</description><pubDate>Thu, 30 Apr 2009 08:42:55 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22966.aspx</link><description>Trent,&lt;/P&gt;&lt;P&gt;Thanks for those pointers. I have now sorted my Pk issue. Not only am I trying to get to grips with StrataFrame but I am also learning what I can do with SQL Server Express and I had overlooked a column property when defining a primary key.&lt;/P&gt;&lt;P&gt;Regards</description><pubDate>Thu, 30 Apr 2009 04:20:25 GMT</pubDate><dc:creator>Ian Hammond</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22929.aspx</link><description>This appears that you do not have a seed on your primary key.&amp;nbsp; The only way that you would get this is one of the following ways:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You are expecting the BO to support Auto-Incrementing keys and do no have your PK setup with an auto-incrementing seed on your table.&lt;/LI&gt;&lt;LI&gt;You have a PK field defined on your table and are supposed to set this yourself as it is not auto-incrementing and then do not set this value.&lt;/LI&gt;&lt;LI&gt;You are using CRUD sprocs and have created these manually and are not updating the PK field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The manifestation of your issue will be one of these elements.&amp;nbsp; There may be some other factors involved, but the root is going to most likely be one of these things (or a combination of them).</description><pubDate>Wed, 29 Apr 2009 08:34:26 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22928.aspx</link><description>When I execute my Save command from the Maintenance form I get the following message dumped:&lt;/P&gt;&lt;P&gt;BusinessLayerException&lt;BR&gt;&amp;nbsp; An error occurred while saving an the data to the server.&lt;BR&gt;DataLayerSavingException&lt;BR&gt;&amp;nbsp; Cannot insert the value NULL into column 'config_pk', table 'ConfigHLS.dbo.Config'; 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 'config_pk', table 'ConfigHLS.dbo.Config'; 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()&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.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)&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.ScrollableControl.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStrip.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;&lt;/P&gt;&lt;P&gt;I have also switched debug on and the last sql command is: &lt;/P&gt;&lt;P&gt;&lt;TABLE cellSpacing=0&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Command #: &lt;/TD&gt;&lt;TD&gt;4 &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Timestamp: &lt;/TD&gt;&lt;TD&gt;2009-04-29 13:24:52.312 &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=TitleSpacer colSpan=2&gt;General Command Settings &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Command Type: &lt;/TD&gt;&lt;TD&gt;Text &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Object Type: &lt;/TD&gt;&lt;TD&gt;System.Data.SqlClient.SqlCommand &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Connection String: &lt;/TD&gt;&lt;TD&gt;Data Source=IANASUS\SQLEXPRESS;Initial Catalog=ConfigHLS;Integrated Security=True;Persist Security Info=False;Asynchronous Processing=True &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;Transaction: &lt;/TD&gt;&lt;TD&gt;False &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=Title colSpan=2&gt;Command Settings &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;CommandText: &lt;/TD&gt;&lt;TD&gt;INSERT INTO [dbo].[Config] ([tableId], [fieldName], [displayName], [pageNo], [pagePosn], [fieldType], [entries], [multiChoice], [enquire], [checkSpell], [inReview], [length], [lines], [contents]) VALUES (@tableId, @fieldName, @displayName, @pageNo, @pagePosn, @fieldType, @entries, @multiChoice, @enquire, @checkSpell, @inReview, @length, @lines, @contents); SELECT [config_pk] FROM [dbo].[Config] WHERE config_pk = SCOPE_IDENTITY(); &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=Title colSpan=2&gt;Command Parameters &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@tableId: &lt;/TD&gt;&lt;TD&gt;'1' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: tableId | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@fieldName: &lt;/TD&gt;&lt;TD&gt;'&amp;nbsp;Genus' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: String | Size: 52 | Direction: Input | SourceColumn: fieldName | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@displayName: &lt;/TD&gt;&lt;TD&gt;'Genus' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: String | Size: 52 | Direction: Input | SourceColumn: displayName | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@pageNo: &lt;/TD&gt;&lt;TD&gt;'0' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: pageNo | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@pagePosn: &lt;/TD&gt;&lt;TD&gt;'0' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: pagePosn | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@fieldType: &lt;/TD&gt;&lt;TD&gt;'1' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: fieldType | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@entries: &lt;/TD&gt;&lt;TD&gt;'False' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: entries | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@multiChoice: &lt;/TD&gt;&lt;TD&gt;'False' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: multiChoice | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@enquire: &lt;/TD&gt;&lt;TD&gt;'False' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: enquire | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@checkSpell: &lt;/TD&gt;&lt;TD&gt;'False' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: checkSpell | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@inReview: &lt;/TD&gt;&lt;TD&gt;'False' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: inReview | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@length: &lt;/TD&gt;&lt;TD&gt;'10' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: length | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@lines: &lt;/TD&gt;&lt;TD&gt;'1' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: lines | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=RowHeader&gt;@contents: &lt;/TD&gt;&lt;TD&gt;'&amp;nbsp;' &lt;SPAN class=ParameterInfo&gt;&lt;FONT color=#777777&gt;[DbType: String | Size: -1 | Direction: Input | SourceColumn: contents | SourceVersion: Current]&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I hope this is of some use</description><pubDate>Wed, 29 Apr 2009 07:29:14 GMT</pubDate><dc:creator>Ian Hammond</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22913.aspx</link><description>Hi Paul,&lt;/P&gt;&lt;P&gt;Sorry about the delay in responding. I am trying to insert a new record. I have declared the pk to be an integer. In the Business object I have :&lt;/P&gt;&lt;P&gt;PrimaryKeyIsAutoIncremented= true and PrimaryKeyIsUpdatable=false.&lt;/P&gt;&lt;P&gt;Many thanks</description><pubDate>Tue, 28 Apr 2009 10:26:39 GMT</pubDate><dc:creator>Ian Hammond</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22912.aspx</link><description>Hi Greg,&lt;/P&gt;&lt;P&gt;Thanks for the reply. Sorry about the delay in responding. I will try and lay-out what I'm trying to achieve. I want to have 2 fields in a configuration database labeled FieldName and DisplayName say. These fields are bound to textBox1 and textBox2 respectively. I am trying to initialise textBox2 with the contents of textBox1 as the user is entering into textBox1. The user can change the displayname independently by entering into textBox2.&lt;/P&gt;&lt;P&gt;Many thanks</description><pubDate>Tue, 28 Apr 2009 10:20:04 GMT</pubDate><dc:creator>Ian Hammond</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22894.aspx</link><description>All good questions from the guys, Ian.&amp;nbsp; Could you elaborate on #1 what you are trying to accomplish.&amp;nbsp; Also, Paul's questions on #2 are needed to help as well.&amp;nbsp; Thanks.</description><pubDate>Mon, 27 Apr 2009 08:21:36 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22880.aspx</link><description>Hi Ian,&lt;/P&gt;&lt;P&gt;For you # 1&amp;nbsp;question try handling the property changing event on the business object. To enable the event look under advanced options in the business object mapper. you should be able to handle it and do something like to code below to accomplish what you want&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&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;Private&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;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; BizCustomers1_FieldPropertyChanging(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; sender &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&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;Object&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;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; BizCustomers.BizCustomersFieldChangingEventArgs) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Handles&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; BizCustomers1.FieldPropertyChanging&lt;/P&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; e.FieldChanging = BizCustomers.BizCustomersFieldNames.cust_Name &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;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'check to see if adding&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; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.BizCustomers1.EditingState = BusinessEditingState.Adding &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#008000&gt;'set shrtname field to the first 7 characters of the customer name while adding&lt;/FONT&gt;&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;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.BizCustomers1.cust_ShrtName = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.BizCustomers1.cust_Name.&lt;FONT size=2&gt;PadRight(7, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;" "&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;).&lt;/FONT&gt;Substring(0, 7)&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;/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;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;/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;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;Sub&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;For # 2 are you only getting the error when you update a record? &lt;/P&gt;&lt;P&gt;Are you using an integer PK and having SQL handle the increment or are you passing in your own PK?</description><pubDate>Fri, 24 Apr 2009 15:10:54 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: Maintennace Forms and PK queries</title><link>http://forum.strataframe.net/FindPost22879.aspx</link><description>Ian,&lt;br&gt;
&lt;br&gt;
I'm not following what your are trying to do in #1.  In number two, you likely need to handle the SetDefaultValues for the BO and set some defaults.  Value types (structures) will have a default set automatically, but reference types are null (Nothing) by default.  So, if one of those fields is marked Not Null, you'll get this kind of error.</description><pubDate>Fri, 24 Apr 2009 11:12:16 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>