Solved

DataGrid doesn't save in the mdf file

Posted on 2009-03-30
3
352 Views
Last Modified: 2013-11-07
Hi..

I 'm using VS2008, to make a windows based applicatin using .net framework 2.0

I made a SQL datababse on my machine (mdf file), new table using the server explorer then on a new form I added the new table from the datasources explorer as a grid view ( by drag and drop )
on running the application after editing and adding new rows , and pressing the save button
nothing is saved
i mean after closing visual studio and opening again or even running the application again ,
the database file has no data
what is missing ??
0
Comment
Question by:drtoto82
  • 2
3 Comments
 
LVL 9

Assisted Solution

by:Gorkem Yuksel
Gorkem Yuksel earned 20 total points
ID: 24019929
Hi,

If you are using Begin/End edit methods, you will also need to call the comitchanges() method to send the information to the database.  Otherwise all changes are held in memory until they are comitted.

Cheers,

G.
0
 
LVL 5

Author Comment

by:drtoto82
ID: 24040942
where should i call this method ?
How ?
Gimme an example plz..
0
 
LVL 5

Accepted Solution

by:
drtoto82 earned 0 total points
ID: 24343590
I edited the code on the Save button to be like that..

private void groupsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.groupsBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.editGroups);
            try
            {
                this.editGroups.AcceptChanges();
                MessageBox.Show("Data Updated Successfully", "Data Updated");
            }
            catch
            {
                MessageBox.Show("An error Occured", "Error");
            }
 
        }

Open in new window

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS subreport with parameter 3 50
HttpPostedFile 1 30
Firing an ASP.NET event on selection of a JQuery datepicker 4 31
Winform Module - What is the ASP.Net equiv 2 28
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

820 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