Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 17th, 2006, 8:33 AM   #1
daz4805
Newbie
 
Join Date: Feb 2006
Posts: 3
Rep Power: 0 daz4805 is on a distinguished road
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
daz4805 is offline   Reply With Quote
Old Feb 17th, 2006, 9:01 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 17th, 2006, 9:08 AM   #3
daz4805
Newbie
 
Join Date: Feb 2006
Posts: 3
Rep Power: 0 daz4805 is on a distinguished road
Many Apologies
daz4805 is offline   Reply With Quote
Old Feb 17th, 2006, 11:35 AM   #4
daz4805
Newbie
 
Join Date: Feb 2006
Posts: 3
Rep Power: 0 daz4805 is on a distinguished road
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)
{ 

try 
{ 

// Clear out the current edit 

this.BindingContext[objCallout_Screen,"CALLOUT_DETAILS"].EndCurrentEdit(); 
this.BindingContext[objCallout_Screen,"CALLOUT_DETAILS"].AddNew();

} 

catch (System.Exception eEndEdit)  

{ 

System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age); 
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
daz4805 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC