Mokmeuh
Mokmeuh

Reputation: 885

Changing dataTable with select

I have this command

dSet.Tables("Articles_table").Select("Nom = '" & sName & "'")("Quantité")

I wonder what do I put after the .select who return a row but not the method of it for me to change the code

"Nom" is a column "Quantité" is also a column

Basicly what I want to do is to update a specific data in "Articles_table" Where the name is sName in the Quantité row

I've looked around but It seems I can't get the right keyword with google, ... , And I'm sure someone tried this before me so If it's a double post just point it out on me, if not I would be please to receive your help x)

Upvotes: 2

Views: 57

Answers (1)

Steve
Steve

Reputation: 216302

The Select method of a DataTable return an array of DataRows not a single DataRow

You need to add the indexer of the row

 Dim rows = dSet.Tables("Articles_table").Select("Nom = '" & sName & "'")
 If rows.Count > 0 Then
     Dim qta = rows(0)("Quantité")
     ....
 End If

Also I really suggest you to split your code in separate lines. You have an exception waiting to happen if the select doesn't return any row.

Upvotes: 1

Related Questions