Solved

Using recordsets or equivelant in vb express working with sql server tables

Posted on 2014-02-24
1
170 Views
Last Modified: 2014-02-28
I am working vb express 2010 and connected to an SQL server in Management Studio Express 2008.

I need to lookup each instance of startdate in tbl_1 and check every row of tbl_2, inserting a the downtime code from tbl_1 when the downtimecode is not currently null

tbl_1

ID     StartDate      StopDate       StopTime    DowntimeCode

1       2014-01-01   2014-01-02         24                     3
2       2014-01-02   2014-01-03         31                     6
3


tbl_2

ID     StartDate      StopDate       StopTime    DowntimeCode
         2014-01-01                                                          3
         2014-01-01                                                          3
         2014-01-02                                                          6

I must do this procedure from vb.

Thankyou very much for your assistance.
0
Comment
Question by:SweetingA
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39885207
You can populate two datatables in vb.net and then use following code


For i As Integer = 0 to dTable1.Rows.Count - 1
  dTable2.DefaultView.RowFilter = "StartDate='" & dTable1.Rows(i).item("StartDate")
  if dTable2.DefaultView.Count > 0
     dTable1.Rows(i).Item("DowntimeCode") = dTable2.DefaultView.Item(0).Item("DowntimeCode")
  End If
Next

Open in new window



*Untested code
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

792 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