Solved

DataGrid doesn't save in the mdf file

Posted on 2009-03-30
3
360 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
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…
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 new code templates in NetBeans IDE 8.0 for Windows.

690 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