Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > HELP!!!!unable to save data using window form!!!!URGENT!!!
 

HELP!!!!unable to save data using window form!!!!URGENT!!!

Hi...can someone help me to figure out what's going on to my form?

Currently, I'm doing an assignment using the window form and I'm using Visual studio 2005 and SQL express edition. I'm trying to save data from the window form but it seems like nothing change to my database. After i run the program, enter the data to form, close the form, then preview the dataset's data and database table data.BOTH remain same, the data unable to save to the database.

But when I try to save data using Web Form, it works very well.

So can someone tell me what's wrong with my setting???...For your information, i didn't configure the SQL server and let it remain the default setting.

So, what should I need to do now?????????????PLs HELP!!!!!!!!

Angel Lee  Wednesday, March 08, 2006 8:29 PM

Hello. You didn't specify your problem clearly.

But if you are using SqlDataAdapter and DataSet, then after inserting data in your windows from you have to update the DataSet using SqlDataAdapter.Update(DataSet)

Regards

Bappi  Monday, March 13, 2006 6:08 AM

Hello Angel Lee,

had the same problem as you - andI think I solved it:

I drag-and-dropped a table "Recordings" from an existing DataSet "musicDataSet" into my form and was happy to see my table as DataGridView "recordingsDataGridView".

This might apply tosimilar control elements, too - haven't tested it already.

After starting the application, iwas able toedit the values in this DataGridView - but unfortunately the values were not stored to the database.
I assumed that values are storedMS Access-like:
edit a value, change or leave the record and the value is stored in the database / table.
Wrong - You have to "tell" the DataGridView that it has to update the database / table when leaving the record, or to be more exactly: when editing the cell ends:

Open the Properties of your DataGridView, select "Events", doubleclickinto the empty field right to "CellEndEdit" - this is the event that will happen, when you leave the cell after editing it.

The Code-Window will pop-up, presenting you an empty function:

private void recordingsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{

}

Enter the following lines into this function:

this.Validate();
// recordingsBindingSource = the name of my bindingSource

this
.recordingsBindingSource.EndEdit();
//recordingsTableAdapter = the name of my tableAdapter
this.recordingsTableAdapter.Update(this.musicDataSet.Recordings);

Now your values will bestored to the database / table after you finished editing them.

Hope, I could solve your problem.

Michael__H  Monday, April 10, 2006 3:14 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView in CWinFormsControl hangs after ALT + TAB
• Cant Add Controls To a form that is derived from a base class with TableLayout
• Find
• capture the Keyup & KeyDown in a Datagrid
• Operation can only be performed on cells that belong to a DataGridView control
• Bug databinding to TabPage.Text property
• Make image field empty (in SQL table)
• Error message when trying to update a TableAdapter
• Dataset Error: IndexOutOfRangeException
• ERROR [HY001][Microsoft][ODBC dbase driver] System resource exceeded