Solved

DataGrid doesn't save in the mdf file

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cs.Designer Issue(2) 2 23
How search webpage "viewable text" only 1 30
C# Error - Add Failed 12 52
Achieve json result 2 35
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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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 use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

747 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

15 Experts available now in Live!

Get 1:1 Help Now