Solved

DataGrid doesn't save in the mdf file

Posted on 2009-03-30
3
356 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
[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
  • 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

Technology Partners: 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

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…
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 perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

742 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