Group: Forum Members
Posts: 57,
Visits: 277
|
Hi, I have the following 2 queries: 1) I have a maintenance form with 2 bound textboxes, 1 textbox for a db field name (textBox1) 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 Change event on textBox1 I set textBox2.Text = textBox.Text 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. Does anyone have an explanation for this? 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? many thanks
|
Group: Forum Members
Posts: 57,
Visits: 277
|
When I execute my Save command from the Maintenance form I get the following message dumped: BusinessLayerException An error occurred while saving an the data to the server. DataLayerSavingException Cannot insert the value NULL into column 'config_pk', table 'ConfigHLS.dbo.Config'; column does not allow nulls. INSERT fails. The statement has been terminated. SqlException Cannot insert the value NULL into column 'config_pk', table 'ConfigHLS.dbo.Config'; column does not allow nulls. INSERT fails. The statement has been terminated. Source : MicroFour StrataFrame Business Stack Trace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteReader(DbCommand Command, Boolean IsTransactional, String TransactionKey) at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand) at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler) at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams) at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save() at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e) at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I have also switched debug on and the last sql command is: 4 | 2009-04-29 13:24:52.312 | General Command Settings | Text | System.Data.SqlClient.SqlCommand | Data Source=IANASUS\SQLEXPRESS;Initial Catalog=ConfigHLS;Integrated Security=True;Persist Security Info=False;Asynchronous Processing=True | False | Command Settings | 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(); | Command Parameters | '1' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: tableId | SourceVersion: Current] | ' Genus' [DbType: String | Size: 52 | Direction: Input | SourceColumn: fieldName | SourceVersion: Current] | 'Genus' [DbType: String | Size: 52 | Direction: Input | SourceColumn: displayName | SourceVersion: Current] | '0' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: pageNo | SourceVersion: Current] | '0' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: pagePosn | SourceVersion: Current] | '1' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: fieldType | SourceVersion: Current] | 'False' [DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: entries | SourceVersion: Current] | 'False' [DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: multiChoice | SourceVersion: Current] | 'False' [DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: enquire | SourceVersion: Current] | 'False' [DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: checkSpell | SourceVersion: Current] | 'False' [DbType: Boolean | Size: 0 | Direction: Input | SourceColumn: inReview | SourceVersion: Current] | '10' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: length | SourceVersion: Current] | '1' [DbType: Int32 | Size: 0 | Direction: Input | SourceColumn: lines | SourceVersion: Current] | ' ' [DbType: String | Size: -1 | Direction: Input | SourceColumn: contents | SourceVersion: Current] |
I hope this is of some use
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
This appears that you do not have a seed on your primary key. The only way that you would get this is one of the following ways: - 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.
- 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.
- You are using CRUD sprocs and have created these manually and are not updating the PK field.
The manifestation of your issue will be one of these elements. 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).
|