Solved

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

Posted on 2014-02-24
1
162 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now