Solved

Windows Forms C# Save Event

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's the most efficient way to load up a couple of large table in C#? 5 45
C# HTTP GET method sample code 3 55
Coding C# in Linux 8 60
C# Comparing String Arrays. 5 39
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 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

10 Experts available now in Live!

Get 1:1 Help Now