Solved

Windows Forms C# Save Event

Posted on 2015-01-21
5
136 Views
Last Modified: 2015-01-22
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
0
Comment
Question by:hhnetworks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40563302
It looks like your TableAdpateraManager does not have a link to a valid TableAdapters

This Microsoft walk-through could help you here
https://msdn.microsoft.com/en-us/library/bb384432.aspx
0
 

Author Comment

by:hhnetworks
ID: 40563337
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?
0
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 500 total points
ID: 40563343
From the Walkthrough

Data-bound controls with descriptive labels appear on the form, together with a TableAdapterManager component, a toolbar (BindingNavigator) for navigating records. A typed DataSet, TableAdapter, and a BindingSource, appear in the component tray.

TableAdapters provide communication between your application and a database. More specifically, a TableAdapter connects to a database, executes queries or stored procedures, and either returns a new data table populated with the returned data or fills an existing DataTable with the returned data. TableAdapters are also used to send updated data from your application back to the database.
https://msdn.microsoft.com/en-us/library/bz9tthwx.aspx
0
 

Author Comment

by:hhnetworks
ID: 40563408
Thank you. I will try that in the morning and post my results.
0
 

Author Comment

by:hhnetworks
ID: 40564067
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:

 
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");
            }
            
        }

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question