Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to edit row in DataRow

Status
Not open for further replies.

bulsecoip

Programmer
Feb 13, 2007
3
PH
Hi,
Im just newbie in vb.net and have difficulties editing the row in DataRow. Can someone please help me. Thanks
 
To assign a value:
Code:
DataRow.Item("ColumnName") = Value
'Or
DataRow.Item(ColumnNumber) = Value
Or to retrieve a value:
Code:
Value = DataRow.Item("ColumnName")
'Or
Value = DataRow.Item("ColumnNumber")

Depending on what you are editting (DataSet/Table or Database), this should work.

If it doesn't then please give more info of where you are getting the database from or creating the schema (tables/column names)...
 
hi cjelec, how can point to the right row to be edit in a datarow?!?
 
You could either use
Code:
DataTable.Rows(RowNumber)
'Or
Dim dr() As DataRow = DataTable.Select("AColumn = 'abc'")
The second allows you to find a row that has a column or columns containing data you want to find...
Say for example, you have a table with peoples firstnames, surnames, age...
You could use the following:
Code:
'FirstName
Dim dr() As DataRow = DataTable.Select("FirstName = 'Bob'")
'FirstName and surname
Dim dr() As DataRow = DataTable.Select(FistName = 'Bob' AND Surname = 'Smith')
'Age equal or above 30
Dim dr() As DataRow = DataTable.Select("Age >= 30")
If you are just after one record then use code to see if the dr() has items 'If dr.Length > 0 Then' and use dr(0) to access the first record returned.

That should keep you going...
 
hi cjelec, thank you very much for the help. I use the codes you give me and it works :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top