DataTable

jvcoach23

Member
Joined
Feb 21, 2005
Messages
17
Location
IL
Programming Experience
1-3
how do you update a column in a row in a datatable. This datatable is going to be populated orginally from a database, but after that all the updates to it won't be going back to the database, they are just goign to be used for display. So if i I have a datatable with the column names of Name, col1, col2 and the first row is looks like this..


Name col1 col2
a2 30 15
b2 10 13.3
c2 100 18

now i click on a button1 to update from a text box the value to teh datatable. I know that I want to update col1 where name = a2. How do I do that. I've looked around.. but I must not be using the right key words or not understanding what I'm seeing. let's say the datatables name is dt.

someone willing to lend a hand
thanks
shannon

Oh yeah.. I'm using vb.net in a windows form. thanks
 
HI,
Let's say if Your Name is Unique or primary key than u can use ............

Dim drNew As DataRow

drNew = pi_dtTable.Select("name='a2'")(0)

drNew.Item("Col1") =111

pi_dtTable.EndInit()

I hope this will help u......................

Regards,
Ritesh
 
Hi ritesh,

can you please tell me how i can read values stored in a datatable? i m not being able to figure out the syntax to do so. thanx a lot in advance man..

aalok
 
Hi Alok,
U can loop through each row of the datatable as..........

for intCounter = 0 to dtTable.rows.count-1

strName = dtTable.rows(intCounter).item("NameOfCol")

next

Regards,
Ritesh
 
Back
Top