hhnetworks
asked on
Windows Forms C# Save Event
I have a small Windows Forms app (C#) that Im developing to manage inventory for an online store.
Im having a terrible time trying to Save Data to my SQL2008 DB. I continue to receive an Exception telling me that the TableAdapterManager contains no connection information.
All of my queries, forms and table adapters seem to be working nicely; I just cant commit any changes to the database.
Ive included a screenshot of my code and the error below.
Thanks in advance
1-21-2015-4-31-38-PM.png
Im having a terrible time trying to Save Data to my SQL2008 DB. I continue to receive an Exception telling me that the TableAdapterManager contains no connection information.
All of my queries, forms and table adapters seem to be working nicely; I just cant commit any changes to the database.
Ive included a screenshot of my code and the error below.
Thanks in advance
1-21-2015-4-31-38-PM.png
ASKER
Thanks. I did see this page early in the day, but my Table Adapter Manager and all other settings are setup correctly.
Googling that error message today, I cannot find anyway in the Designer or with code to add a "link to the Table Adapter".
If Im only using a single table, do I even need the AdapterManager at all?
Googling that error message today, I cannot find anyway in the Designer or with code to add a "link to the Table Adapter".
If Im only using a single table, do I even need the AdapterManager at all?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. I will try that in the morning and post my results.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for hhnetworks's comment #a40563408
for the following reason:
Thank you for your help. The following code from that last link worked perfectly. The answer in my case is to Save via the TableAdapter, and not the TableAdapterManager. Im still puzzled why the Manager didnt work, as it was autocreated when I built the form.
The correct code I used is here:
Accepted answer: 0 points for hhnetworks's comment #a40563408
for the following reason:
Thank you for your help. The following code from that last link worked perfectly. The answer in my case is to Save via the TableAdapter, and not the TableAdapterManager. Im still puzzled why the Manager didnt work, as it was autocreated when I built the form.
The correct code I used is here:
private void SaveButton_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.taEditBindingSource.EndEdit();
this.taEditTableAdapter.Update(this.ONLINE_STOREDataSet);
var form = new SaveConfirmed(); //Custom Confirmation Box
form.Show();
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed");
}
}
This Microsoft walk-through could help you here
https://msdn.microsoft.com/en-us/library/bb384432.aspx