Solved

DataGrid doesn't save in the mdf file

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 46
Simple Injector with Web Service 4 41
HttpPostedFile 1 26
MailAddress in vb 4 15
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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.

809 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