Solved

Windows Forms C# Save Event

Posted on 2015-01-21
5
98 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
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Michael74
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:
Michael74 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now