Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
| Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2004, 12:17 PM
Registered User
 
Join Date: Mar 2004
Location: Lafayette Hill, PA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO - Updating two tables?

I am trying to figure out how I can display data on a VB form that comes from several tables and can be updated. I was using an ADO data control, but it is causing me problems when I join tables.

Basically I want to display and edit...

Table1.Name
Table1.Phase
Table2.StartDate
Table2.EndDate
Table3.TypeDesc

Does anyone have any idea how I could do this? Table design is below.

[u]Table1 - Customer</u>
Customer_ID (PK)
Name
Phase
Type_ID

[u]Table2 - Phase</u>
Customer_ID (PK) - FK to Table1
Phase (PK)
StartDate
EndDate

[u]Table3 - Type</u>
Type_ID (PK)
TypeDesc
 
Old April 23rd, 2004, 01:31 AM
Authorized User
 
Join Date: Mar 2004
Location: Brasov, , Romania.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should use a mshflexgrid not linked to any adodb control. You make a recordset from your joined tables and than fill the grid from the recordset row by row

        With rsTemp
            .MoveFirst
            i = 1
            While Not .EOF

                hfgRecords.Rows = i + 1

                hfgRecords.TextMatrix(i, 0) = .Fields("Name").value & ""

                hfgRecords.TextMatrix(i, 1) = .Fields("Phase").value & ""

                hfgRecords.TextMatrix(i, 2) = .Fields("StartDate").value & ""

                hfgRecords.TextMatrix(i, 3) = .Fields("EndDate").value & ""
                hfgRecords.TextMatrix(i, 4) = .Fields("TypeDesc").value & ""

                i = i + 1

                .MoveNext
            Wend
        End With


Lucian Preda
preda_lucian_ro@yahoo.com
 
Old May 19th, 2004, 05:39 AM
Authorized User
Points: 236, Level: 4
Points: 236, Level: 4 Points: 236, Level: 4 Points: 236, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Bucharest, , Romania.
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also,

if you are familiar with SQL ("UPDATE tablename SET field = value,.."), you can build the SQL statement in form of a string and then assign it to a ADO command & execute it.

This is, in my opinion, the most straightforward and controllable way.
It also works with any SQL dialect (Oracle, MySQL, Sybase etc.)

Mike






Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating Tables Brendan Bartley Access 1 December 20th, 2006 10:42 AM
Huge problem updating FoxPro with ADO recordset erankin42 Classic ASP Databases 5 October 18th, 2004 03:08 PM
Updating database records in ASP/ADO aismail3 Classic ASP Databases 5 September 16th, 2004 11:10 PM
ADO and updating records tcarnahan Access 2 June 11th, 2004 09:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.