HighTechTalks DotNet Forums  

Newly added Row fails to update

Dotnet Framework (WinForms DataBinding) microsoft.public.dotnet.framework.windowsforms.databinding


Discuss Newly added Row fails to update in the Dotnet Framework (WinForms DataBinding) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Morris Neuman
 
Posts: n/a

Default Newly added Row fails to update - 05-23-2008 , 10:39 PM






I have a windows form with a Dataset with only one table bound to Details
View controls, all created in VS2005 with designer. I added a button to
create a new record and issue a this.mBDetailsBindingSource.AddNew(); to
create a new blank row in the table and then fill the controls with their
default values. (There is no BindingNavigator for these controls.) Then
when a Save button is pressed I call Validate(), EndEdit and the Update() but
the row does not get sent to the data base.
If I edit an existing record and click Save the update for that row works.

How do I get the new row to be added to the SQL Database table?

Thanks
Morris

Reply With Quote
  #2  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: Newly added Row fails to update - 05-25-2008 , 10:55 PM






Hi Morris,

Based on my understanding, you are able to update the existing records but
cannot insert new records to the database. If I'm off base, please feel
free to let me know.

I perform a test but couldn't reproduce the problem on my side. The main
steps of my test are as follows:
1. Use "Data Source Configuration Wizard" to add a DataSet containing a
DataTable into the project(select menu Data| Add New Data SourceĦ*), which
also generates a TableAdapter for the DataTable.
2. Open the "Data Sources window" (select menu Data | Show Data Sources).
3. From the Data Sources window, click the drop down button on the right
of the DataTable and select "Details" and then drag the DataTable onto a
Form, which generates several controls, a DataSet instance, a BindinSource,
a TableAdapter as well as a BindingNavigator.
4. Delete the BindingNavigator from the Form.
5. Add two Buttons on the Form and handle the Click event of these two
Buttons.
// add a new record
private void button1_Click(object sender, EventArgs e)
{
this.bindingSource1.AddNew();
}
// save changes back to DB
private void button2_Click(object sender, EventArgs e)
{
this.Validate();
this.bindingSource1.EndEdit();
this.tableAdapter1.Update(this.dataSet1.Table1);
}

Since I couldn't reproduce the problem using the same lines of code as
yours, I suspect the reason of your problem is that the InsertCommand is
missing in the TableAdapter for your DataTable. I recommend you check
whether there's an InsertCommand in the TableAdapter or not. To do this:

1. In the Solution Explorer, double click the DataSet file(.xsd file) to
open the DataSet designer.
2. In the DataSet designer, click on the xxxTableAdapter panel and switch
to the Properties window.
3. In the Properties window, check the value of the InsertCommand property.

If the InsertCommand property is (none), click the new option in the drop
down list, and then specify the 'Command Text' and 'Parameters' properties
for the InsertCommand.

Please try my suggestion and let me know the result.

If the problem is still not solved, you may reproduce the problem in a
simple project and send it to me. To get my actual email address, remove
'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: Newly added Row fails to update - 05-25-2008 , 10:55 PM



Hi Morris,

Based on my understanding, you are able to update the existing records but
cannot insert new records to the database. If I'm off base, please feel
free to let me know.

I perform a test but couldn't reproduce the problem on my side. The main
steps of my test are as follows:
1. Use "Data Source Configuration Wizard" to add a DataSet containing a
DataTable into the project(select menu Data| Add New Data SourceĦ*), which
also generates a TableAdapter for the DataTable.
2. Open the "Data Sources window" (select menu Data | Show Data Sources).
3. From the Data Sources window, click the drop down button on the right
of the DataTable and select "Details" and then drag the DataTable onto a
Form, which generates several controls, a DataSet instance, a BindinSource,
a TableAdapter as well as a BindingNavigator.
4. Delete the BindingNavigator from the Form.
5. Add two Buttons on the Form and handle the Click event of these two
Buttons.
// add a new record
private void button1_Click(object sender, EventArgs e)
{
this.bindingSource1.AddNew();
}
// save changes back to DB
private void button2_Click(object sender, EventArgs e)
{
this.Validate();
this.bindingSource1.EndEdit();
this.tableAdapter1.Update(this.dataSet1.Table1);
}

Since I couldn't reproduce the problem using the same lines of code as
yours, I suspect the reason of your problem is that the InsertCommand is
missing in the TableAdapter for your DataTable. I recommend you check
whether there's an InsertCommand in the TableAdapter or not. To do this:

1. In the Solution Explorer, double click the DataSet file(.xsd file) to
open the DataSet designer.
2. In the DataSet designer, click on the xxxTableAdapter panel and switch
to the Properties window.
3. In the Properties window, check the value of the InsertCommand property.

If the InsertCommand property is (none), click the new option in the drop
down list, and then specify the 'Command Text' and 'Parameters' properties
for the InsertCommand.

Please try my suggestion and let me know the result.

If the problem is still not solved, you may reproduce the problem in a
simple project and send it to me. To get my actual email address, remove
'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #4  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: Newly added Row fails to update - 05-27-2008 , 07:56 PM



Hi Morris,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #5  
Old   
Linda Liu[MSFT]
 
Posts: n/a

Default RE: Newly added Row fails to update - 05-27-2008 , 07:56 PM



Hi Morris,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #6  
Old   
rockzZ26
 
Posts: n/a

Default RE: Newly added Row fails to update - 07-01-2008 , 01:56 PM



Hi Linda,

i am facing similar problem. I have been trying to insert some data from a
form to the sql server database. i have tried both ways using command and
using data table adapter. I have even coded everything by hand and have tried
the methodology you specified but when i check the database table, no row is
ever added and yet i get no errors or exceptions.

I am confused because of this behaviour. Any help will be appreciated.

"Linda Liu[MSFT]" wrote:

Quote:
Hi Morris,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #7  
Old   
rockzZ26
 
Posts: n/a

Default RE: Newly added Row fails to update - 07-01-2008 , 01:56 PM



Hi Linda,

i am facing similar problem. I have been trying to insert some data from a
form to the sql server database. i have tried both ways using command and
using data table adapter. I have even coded everything by hand and have tried
the methodology you specified but when i check the database table, no row is
ever added and yet i get no errors or exceptions.

I am confused because of this behaviour. Any help will be appreciated.

"Linda Liu[MSFT]" wrote:

Quote:
Hi Morris,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.

This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.