By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

Programically update a colum in a datagrid

P: n/a
Jim
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the 4th
(invisible) column (employee number). That way when the user saves the data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChanges is
called and the DataAdapter.Update(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine. Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the time.
--
Thanks, Jim
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jim,
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the
4th
(invisible) column (employee number). That way when the user saves the
data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChanges is
called and the DataAdapter.Update(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine.
Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the
time.
--


And why can you not make this?

(Especially the text acceptchanges is interesting by the way, normally you
don't need that with a dataadapter, so show some code around that)

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Jim
Huh?

I have a dataset with a row that has been updated or inserted by the user
via a datagrid. I need to insert a value in one of the grids columns for each
row prior to saving the data. I am using ds.HasChanges to validate that
changes have occured and da.Update(Changes) to update the records. Below is
the update code:

Dim AllChanges As DataSet

If dsAnesthesia.HasChanges() = True Then
AllChanges = dsAnesthesia.GetChanges()
daAnesthesia.Update(AllChanges)
End If

All I want to do is programically insert a value into a bound datagrid
column prior to saving the row. How do I programically access a specific
column whenever the user is either adding or updating a record using a
datagrid.
--
Thanks, Jim
"Cor Ligthert [MVP]" wrote:
Jim,
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the
4th
(invisible) column (employee number). That way when the user saves the
data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChanges is
called and the DataAdapter.Update(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine.
Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the
time.
--


And why can you not make this?

(Especially the text acceptchanges is interesting by the way, normally you
don't need that with a dataadapter, so show some code around that)

I hope this helps,

Cor

Nov 21 '05 #3

P: n/a
Jim,

Sorry, I misreaded haschanges for acceptchanges.

However why not just before you update loop through the datatable.

If dsAnesthesia.HasChanges() = True Then
AllChanges = dsAnesthesia.GetChanges() for each dr in AllChanges.Tables(0).rows
'assuming it is one table
dr.item(3) = "whatever"
next daAnesthesia.Update(AllChanges) dsAnestesia.acceptchanges
'with getchanges you get a copy therefore the update changes will not be
done by the dataadapter End If


To hide the column in a simple way you can use this sample.

http://www.windowsformsdatagridhelp....3-a3539697edbd

I hope this helps,

Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.