![]() |
DataBinding in C#
Hi,
I am very new to C# programming and trying to find my feet with it all!! i am building an application for my dissertation and i am having a few problems. I am using the data form wizzard to generate a form that will allow me to insert, update and delete data from a table already created in Oracle 10g. The insert, update and delete statements have been created in Oracle PL/SQL Package Bodies which compile successfully and run as they should. The code is too much to copy in total but i will be happy to send any that might be helpful! The problem i am having is when i try and add a row to the form. I can enter all of the data but it does not actually add anything to the database. When i use the wizzard to create a "all records in a grid" form the insert update etc works fine within the packages but when i create the form with navigation controls etc using the wizzard i am unable to add data to the database. The method for this add button is as follows: - private void btnAdd_Click(object sender, System.EventArgs e) { try { // Clear out the current edits this.BindingContext[objCallout_Screen,"CALLOUT_DETAILS"].EndCurrentEdit(); this.BindingContext[objCallout_Screen,"CALLOUT_DETAILS"].AddNew(); } catch (System.Exception eEndEdit) { System.Windows.Forms.MessageBox.Show(eEndEdit.Message); System.Windows.Forms.MessageBox.Show("Insert Procedure did not complete Successfully"); } this.objCallout_Screen_PositionChanged(); } Does anyone know why this would not add any data to the database table?? The Insert has been defined with the parameters that are expected within the procedure. The update procedure however works fine which uses the method within c# as follows: - private void btnUpdate_Click(object sender, System.EventArgs e) { try { // Attempt to update the datasource. this.UpdateDataSet(); } catch (System.Exception eUpdate) { // Add your error handling code here. // Display error message, if any. System.Windows.Forms.MessageBox.Show(eUpdate.Message); } this.objCallout_Screen_PositionChanged(); } this.UpdateDataSet calls the following: - public void UpdateDataSet() { // Create a new dataset to hold the changes that have been made to the main dataset. Timesheet.Callout_Screen objDataSetChanges = new Timesheet.Callout_Screen(); // Stop any current edits. this.BindingContext[objCallout_Screen,"CALLOUT_DETAILS"].EndCurrentEdit(); // Get the changes that have been made to the main dataset. objDataSetChanges = ((Timesheet.Callout_Screen)(objCallout_Screen.GetChanges())); // Check to see if any changes have been made. if ((objDataSetChanges != null)) { try { // There are changes that need to be made, so attempt to update the datasource by // calling the update method and passing the dataset and any parameters. this.UpdateDataSource(objDataSetChanges); objCallout_Screen.Merge(objDataSetChanges); objCallout_Screen.AcceptChanges(); } catch (System.Exception eUpdate) { // Add your error handling code here. throw eUpdate; } // Add your code to check the returned dataset for any errors that may have been // pushed into the row object's error. } this.LoadDataSet(); Any help would be very much appreciated as i have hit a brick wall now!! Thanks for your help!! Darren |
Please check out the forum's rules/FAQ and a "How to Post..." thread. You should learn about code tags, which are a courtesy to your potential helpers.
|
Many Apologies
|
Here is the post in the correct format
I am very new to C# programming and trying to find my feet with it all!! i am building an application for my dissertation and i am having a few problems. I am using the data form wizzard to generate a form that will allow me to insert, update and delete data from a table already created in Oracle 10g. The insert, update and delete statements have been created in Oracle PL/SQL Package Bodies which compile successfully and run as they should. I have had a look in some books and have searched google for an answer to my problem but i cant find one. The problem i am having is when i try and add a row to the form. I can enter all of the data but it does not actually add anything to the database when i click the add button. When i use the wizzard to create a "all records in a grid" form the insert update etc works fine but when i create the form with navigation controls etc using the wizzard i am unable to add data to the database. The method for this add button is as follows: - :
private void btnAdd_Click(object sender, System.EventArgs e)Does anyone know why this would not add any data to the database table?? The Insert has been defined with the parameters that are expected within the procedure. The update procedure however works fine which uses the method within c# as follows: - :
private void btnUpdate_Click(object sender, System.EventArgs e)this.UpdateDataSet(); calls the following: - :
public void UpdateDataSet()Any help would be very much appreciated as i have hit a brick wall now!! Thanks for your help!! Darren |
| All times are GMT -5. The time now is 8:17 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC