Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases 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 July 11th, 2006, 06:49 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Associating a recordset field with a control in a

Suppose I have a SQL JOIN code, how can I refer to the recordset fields when I want to associate some controls on the form with this code programmatically? Assume my code is

visual basic code:SELECT orderDetails.orderId,orderDetails.ProductId, orderDetails.UnitPrice, products.ProductName FROm orderDetails INNER JOIN products ON orderDetails.ProductId = products.ProductId

eg

txtName.text = rst!(field) what will the recordset field be?

Thanks

 
Old July 11th, 2006, 11:00 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Because all of the fields in the result set have unique names—that is, you don't have something like:
SELECT orderDetails.ID,
       orderDetails.orderId,
       orderDetails.ProductId,
       orderDetails.UnitPrice,
           products.ProductName,
           products.ID
FROM orderDetails
INNER JOIN products
        ON orderDetails.ProductId = products.ProductId
—you can simply use the field name:
Code:
    txtName.text = rst!ProductName
 
Old July 12th, 2006, 01:59 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried that but nothing is displayed in the textbox and i dont get any error. I don't know where am going wrong.

 
Old July 12th, 2006, 03:13 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried the code and works well on normal form but not in a TabStrip contol. I have these text boxes inside a frame and this frame is one of the tabs on a tabstrip control. could it be that there is a special way of referencing these textboxes in a tabstrip environment? For trial sake, I have tried this code inside a form's load event but nothing appears in the textboxes.

 
Old July 12th, 2006, 04:48 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorted out! It was something to do with my program flow. Thanks for your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
using an IF statement with a recordset field melkin Classic ASP Components 3 March 20th, 2008 03:04 PM
Variable used in recordset field name the4barkersab Access VBA 1 February 24th, 2008 04:18 PM
bind recordset to field ibgreen SQL Language 0 October 24th, 2006 12:48 PM
Retrieve recordset field value tryntolearn Classic ASP Databases 1 August 8th, 2005 10:22 AM
Variable Recordset Field Name Codesucks VB Databases Basics 6 June 1st, 2004 07:15 AM





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