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
Solved

Windows Forms C# Save Event

Posted on 2015-01-21
5
114 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…

792 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