473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Programically update a colum in a datagrid

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
3 1777
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sadun Sevingen | last post by:
hi i get dataset from'an webservice so i don't have an adaptor... dataset's structure is same as mine database table.... how can i update database table according to dataset...
0
by: Ash | last post by:
Hi, I'm using Vb.NET webform, connecting to sql server database on the local machine. I used datagrid propery builder to add the edit, update and cancel colum. On the code, i have: Private...
2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
11
by: Fred Nelson | last post by:
I have an application in which it would be VERY beneficial if I could obtain the names of the colums in a datagrid. For example dim datagrid1 as new datagrid datagrid1.datasource = (stored...
2
by: Agnes | last post by:
In myDatagrid, there is 3 columns, account code, debit,credit. If the user input some particular a account code in column1 , i need to based on the contect of column1, to disable...
3
by: Bill Nguyen | last post by:
I found that rows in datagrid can be sorted by clicking on the column header. However, this doesn't refresh the .currentindex DataGrid1.CurrentCell.RowNumber I need either to disable colum...
0
by: Jet Mah | last post by:
Hi, Mert I want to update the "read_status" colum when reading data, this is my way as below: //...
5
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically...
3
by: Manikandan | last post by:
Hi, I have table with three columns as below table name:exp No(int) name(char) refno(int) I have data as below No name refno 1 a 2 b 3 c
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.