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

You are currently viewing the VB Databases Basics 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 June 22nd, 2006, 06:08 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving data from a table given a PK value

Hi All,
  I am new to VB programming in general, and even newer to database questions, so please bear with me :) I've looked at a lot of help articles and posts, and come up empty. I think the question must be so basic that no one bothers to address it.

  I have created a DataTable, filled it with data, and identified a column as the PrimaryKey. Now I just want to go into that table with a given value that I know exists in the primary key column, find the appropriate row based on that PK value, and get the value from some other column in the same row.

  Big picture, I have a lot of data that I need to be able to access, add to, sort, etc. (but only within a given execution of the program - I don't want a stand-alone external database). I thought it would be easier to create a data table and use database commands than to use arrays and have to write my own logic to do those functions. If someone thinks that's a bad idea, or has a third alternative that I didn't think of, please let me know.

  I don't know if it matters for the answer to my question, but I am using VB 2005 Express.

Thanks!
 
Old June 22nd, 2006, 12:12 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First of all, using a DataTable is not a bad idea. If it has all the functionality you need, and performs well, there is no reason not to use it.

An alternative would be to create your own collection object inheriting from CollectionBase, and implementing the appropriate interfaces. This would be a very useful exercise as it would greatlty expand your understanding of common programming mechanisms. It would force you to learn about and work with basic OOP concepts that are the foundation of programming today.

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Data From Server x_ray Word VBA 0 June 12th, 2006 10:33 AM
Clustered PK Constr fails to create on big table kapluni SQL Server 2000 5 November 23rd, 2005 06:27 PM
retrieving multiple rows from table blackbeauty SQL Language 1 August 8th, 2005 03:55 AM
Retrieving items from a table - Immediate Help badprogrammer Access VBA 2 May 4th, 2005 02:39 PM
Having problems retrieving an array to a table! penta Access 2 September 27th, 2004 07:23 AM





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