?
Solved

Windows Forms C# Save Event

Posted on 2015-01-21
5
Medium Priority
?
146 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 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