Click here to Skip to main content
16,006,001 members
Home / Discussions / C#
   

C#

 
Generalclosing an open form Pin
.gonad8-Jul-03 4:08
.gonad8-Jul-03 4:08 
GeneralRe: closing an open form Pin
zuhx8-Jul-03 10:29
zuhx8-Jul-03 10:29 
GeneralRe: closing an open form Pin
.gonad8-Jul-03 15:46
.gonad8-Jul-03 15:46 
GeneralUpdating a data table Pin
totig8-Jul-03 1:03
totig8-Jul-03 1:03 
GeneralRe: Updating a data table Pin
Rocky Moore8-Jul-03 1:13
Rocky Moore8-Jul-03 1:13 
GeneralRe: Updating a data table Pin
totig8-Jul-03 1:26
totig8-Jul-03 1:26 
GeneralRe: Updating a data table Pin
totig8-Jul-03 1:58
totig8-Jul-03 1:58 
GeneralRe: Updating a data table Pin
Rocky Moore8-Jul-03 4:51
Rocky Moore8-Jul-03 4:51 
Are you using any DataBinding on your text box?

For an example. I built a WinForm app and used the Pubs database that comes with SQL Server. I built a SQLDataAdapter to "Select * From Stores" and then built a dataset off that data adapter (in my code I called it "dset".

In the Form contructor after initializeComponents(), I called:

sqlDataAdapter1.Fill(dset)

Next, I added a DataGrid to the form and set it's DataSource to "dset.stores".

Next, I put a button on the form called "Updated".

Next, I put a listbox on the form and added three city names to the listbox collection.

Next, I added a text box (given the ID CityBox)

Next, I double clicked on the ListBox causing a SelectedIndexChanged event handler to generate. In that handler I put:

CityBox.Text = (string) ((ListBox) sender).SelectedItem;


Next, I double clicked on the Update Button and it generated the Click event handler which I put this in:

dset.stores[5].city = CityBox.Text;
sqlDataAdapter1.Update(dset);


That was due to knowing the row I wanted to update. I could have put:

dset.stores.FindBystor_id("8042").city = CityBox.Text;
sqlDataAdapter1.Update(dset);


Of course you would use proper error checking and what not but this is just a quick example.

I can select the item, it updates in the text box and then I click update and it writes out the changes. At least it works here.

If you have any of your controls such as the text control databound and you are working with a CurrencyManager, you might check into EndCurrentEdit.

Or if you are using BeginEdit,EndEdit to delay validation on a Row:

DataSet1.storesRow sr = dset.stores.FindBystor_id("8042");
sr.BeginEdit();
sr.city = CityBox.Text;
sr.EndEdit();
sqlDataAdapter1.Update(dset);




Rocky Moore <><
GeneralRe: Updating a data table Pin
STW10-Jul-03 20:49
STW10-Jul-03 20:49 
Generalssh &amp; C# Pin
Karavaev Denis7-Jul-03 23:23
Karavaev Denis7-Jul-03 23:23 
GeneralRe: ssh &amp; C# Pin
Daniel Turini8-Jul-03 2:05
Daniel Turini8-Jul-03 2:05 
Generaldatagrid Pin
Cristian_Dior7-Jul-03 21:29
Cristian_Dior7-Jul-03 21:29 
Questionhow do I change the views using the same frame windows Pin
mdolby7-Jul-03 14:34
mdolby7-Jul-03 14:34 
AnswerRe: how do I change the views using the same frame windows Pin
leppie7-Jul-03 14:42
leppie7-Jul-03 14:42 
GeneralArrays and Threads Pin
albean7-Jul-03 14:05
albean7-Jul-03 14:05 
GeneralRe: Arrays and Threads Pin
leppie7-Jul-03 14:22
leppie7-Jul-03 14:22 
GeneralRe: Arrays and Threads Pin
J. Dunlap7-Jul-03 14:34
J. Dunlap7-Jul-03 14:34 
GeneralRe: Arrays and Threads Pin
leppie7-Jul-03 14:35
leppie7-Jul-03 14:35 
GeneralRe: Arrays and Threads Pin
Daniel Turini7-Jul-03 15:04
Daniel Turini7-Jul-03 15:04 
GeneralRe: Arrays and Threads Pin
albean7-Jul-03 18:02
albean7-Jul-03 18:02 
GeneralYankees Pin
eggie57-Jul-03 11:38
eggie57-Jul-03 11:38 
GeneralRe: Yankees Pin
Rocky Moore7-Jul-03 12:00
Rocky Moore7-Jul-03 12:00 
GeneralRe: Yankees Pin
James T. Johnson8-Jul-03 4:10
James T. Johnson8-Jul-03 4:10 
GeneralMIME decoder Pin
jay_n7-Jul-03 11:26
jay_n7-Jul-03 11:26 
GeneralRe: MIME decoder Pin
Rocky Moore7-Jul-03 12:07
Rocky Moore7-Jul-03 12:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.