Solved

VB.Net - Set value in DataTable row

Posted on 2013-01-29
5
1,770 Views
Last Modified: 2013-01-29
Good Day Experts!

Another day where I have to utilize something in VB.Net that I have not before...hopefully you can help.

I have a DataReader that I am looping through.  Each time around, I need to search for a value from it in a DataTable.  If found in the DataTable, I need to update a value in the DataTable row.  Here is what I have so far:

While sqlRS2rdr.Read()  
          Dim row() As DataRow = tblRS.Select("[GL]='" & sqlRS2rdr.GetValue("GL") & "'")
          If row(0) is Nothing Then

          Else
               'Update row() "TotalPaid" field with sqlRS2rdr.GetValue("TotalPaid")        
          End If
End While

If the GL code value from the DataReader sqlRS2rdr is found in the DataTable tblRS, then update the DataTable tblRS TotalPaid field in the row with the TotalPaid value from the DataReader sqlRS2rdr.  

I cannot seem to find the syntax to accomplish this.  

Can you help?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 38831702
Are u using an sql server database?
GL and TotalPaid are on the same table?
0
 

Author Comment

by:Jimbo99999
ID: 38831718
This is in my VB.Net DataTable.  The DataTable has fields GL,TotalPaid and TotalWeight.  So, when I find the row in the DataTable with the GL from the DataReader then I need to update the TotalPaid in that row.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 38831770
ok sorry..
While sqlRS2rdr.Read()   
          Dim row() As DataRow = tblRS.Select("[GL]='" & sqlRS2rdr.GetValue("GL") & "'")
          If row(0) is Nothing Then

          Else
               sqlRS2rdr.Item("TotalPaid")= ........ 
          End If
End While

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38831779
Use this in else part

row(0)("TotalPaid") = sqlRS2rdr.GetValue("TotalPaid")
0
 

Author Comment

by:Jimbo99999
ID: 38832061
That did the trick...no more syntax error.  

Thanks,
jimbo99999
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question