473,802 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching the database of adodc control joint by various Tables

62 New Member
I have an adodc control that is build with several tables using the select command. I need to search for a record on the adodc, is it possibles? If yes, how?
Dec 5 '06 #1
4 1966
Andrew Thackray
76 New Member
Without seeing your code it is difficult to reply.

However in general there are two methods to do this.

The first is to include a WHERE clause in the ADODC select statement that only causes it to select the records you want. You can do this programatically by buiding the SQL code and then setting the ADODC command to it. This an example of buiding the SQL given that you have two tables, TableA and TableB joined on a field 'RELATED' and TableA has a field called 'COLOR' containing the value you want to look for.

[code]

dim SQL as string
dim Col as string

Col = inputbox("Enter the color you want to find")

SQL = "Select * from TableA inner join TableB on TableA.RELATED = TableB.RELATED "
SQL = SQL & "WHERE TableA.COLOR = '" & Col & "' "


[code]

in this code the variable SQL will contain the select statement that you can set in your ADODC control to return a specific recordset. Note the use of single & double quotes in the code when building the SQL statement

The other technique is to open the recordset and then use the SEEK method on the recordset. However this is cumbersome as you have to retrieve a full table and then search through it
Dec 5 '06 #2
nkechifesie
62 New Member
Thank you very much, I have done that but am stuck on how to connect the sql to the adodc for it to open it.I didnt code my Adodc, so am not familiar with coding it.
this is the code i need to connect to my adodc1

Expand|Select|Wrap|Line Numbers
  1.  
  2. DSearch = "SELECT DISTINCT H_DUTY_PER.H_DUTY_PER_ISST, H_DUTY_PER.H_DUTY_PER_EXPT, H_PER.H_PER_ISST, H_PER.H_PER_EXPT, INS_CERT.INS_CERT_ISST, INS_CERT.INS_CERT_EXPT, MOB_ADV.MOB_ADV_ISST, MOB_ADV.MOB_ADV_EXPT, RD_WORTH.RD_WORTH_ISST, RD_WORTH.RD_WORTH_EXPT, VEH_DESCRIPTION.VEHICLE_NO, VEH_DESCRIPTION.ENGINE_NO, VEH_DESCRIPTION.CHASIS_NO, VEH_LIC.VEH_LIC_ISST, VEH_LIC.VEH_LIC_EXPT, VEH_TYPE.VEHICLE_TYPE From H_DUTY_PER, H_PER, INS_CERT, MOB_ADV, RD_WORTH, VEH_DESCRIPTION, VEH_LIC, VEH_TYPE WHERE VEH_DESCRIPTION.VEHICLE_ID=VEH_TYPE.VEHICLE_ID And VEH_DESCRIPTION.VEHICLE_NO=VEH_LIC.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=H_DUTY_PER.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=H_PER.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=INS_CERT.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=MOB_ADV.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=RD_WORTH.VEHICLE_NO"
  3.         DSearch = DSearch & " WHERE VEH_DESCRIPTION.VEHICLE_NO = '" & VehNo & "'"
  4.  
Dec 5 '06 #3
nkechifesie
62 New Member
I have made the code better for your understanding below

Expand|Select|Wrap|Line Numbers
  1.  
  2. DSearch = "SELECT DISTINCT H_DUTY_PER.H_DUTY_PER_ISST, 
  3. H_DUTY_PER.H_DUTY_PER_EXPT, H_PER.H_PER_ISST, 
  4. H_PER.H_PER_EXPT, INS_CERT.INS_CERT_ISST, 
  5. INS_CERT.INS_CERT_EXPT, MOB_ADV.MOB_ADV_ISST, 
  6. MOB_ADV.MOB_ADV_EXPT, RD_WORTH.RD_WORTH_ISST,
  7. RD_WORTH.RD_WORTH_EXPT, VEH_DESCRIPTION.VEHICLE_NO,
  8. VEH_DESCRIPTION.ENGINE_NO, VEH_DESCRIPTION.CHASIS_NO, VEH_LIC.VEH_LIC_ISST, VEH_LIC.VEH_LIC_EXPT, 
  9. VEH_TYPE.VEHICLE_TYPE From H_DUTY_PER, H_PER, INS_CERT, 
  10. MOB_ADV, RD_WORTH, VEH_DESCRIPTION, VEH_LIC, VEH_TYPE 
  11. WHERE VEH_DESCRIPTION.VEHICLE_ID=VEH_TYPE.VEHICLE_ID And VEH_DESCRIPTION.VEHICLE_NO=VEH_LIC.VEHICLE_NO AND 
  12. VEH_DESCRIPTION.VEHICLE_NO=H_DUTY_PER.VEHICLE_NO AND 
  13. VEH_DESCRIPTION.VEHICLE_NO=H_PER.VEHICLE_NO AND 
  14. VEH_DESCRIPTION.VEHICLE_NO=INS_CERT.VEHICLE_NO AND 
  15. VEH_DESCRIPTION.VEHICLE_NO=MOB_ADV.VEHICLE_NO AND 
  16. VEH_DESCRIPTION.VEHICLE_NO=RD_WORTH.VEHICLE_NO"
  17. DSearch = DSearch & " WHERE VEH_DESCRIPTION.VEHICLE_NO = '" & VehNo & "'"
  18.  
Dec 5 '06 #4
Andrew Thackray
76 New Member
The type of code you need to retrieve records using ADODB data objects is as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim Conn as ADODB.connection
  3. Dim Rs as ADODB.Recordset
  4. DIim SQL as string
  5. conn.connectstring = "The string needed to connect to your database"
  6. conn.connect
  7.  
  8. ' put the code to build your SQL string in the variable SQL here
  9.  
  10. rs.open SQL,conn,adopendynamic
  11. if rs.bof = true then
  12.  'Put your code for handling no records returned here
  13. end if
  14.  
  15. rs.movefirst
  16.  
  17.  ' Put your code for handling a record here. Fields in the record are referencedwith the syntax rs!Fieldname
  18.  
  19.  
  20.  
use the vb help to look up the syntax & examples for ADODB.Connectio n and ADODB.Recordset objects

good luck
Dec 5 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
7525
by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I have an series of interactive HTML forms. The user begins a Cookie session. A database connection is opened and a transaction is begun. After the user goes through any number of pages where they update the database they finish on a page where...
0
3647
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
9
18750
by: Mourad | last post by:
Hi All, Is it possible to create a Make Table query in access (2.0 and 2003) that creates the table into a SQL Server database? Following the steps: 1- Create New Query 2- Set Query Type as Make-Table query 3- Enter table name 4- Click "Another Database", click Browse, then I cannot see anything
4
2015
by: psyvanz | last post by:
Im a college student, my program is a computerized enrollment system, Im using MS ACCESS database in connecting my VB6 program form. Inside i'd created two tables, named "tbstudentinfo" and "tbstudentfees". In my 1st table i renamed my fieldname to STUDENTNUMBER and STUDENTNAME on the second fieldname, then below i entered (0001) for studnumber and (Paul) for studname. The 2nd table is almost the same with the 1st table but i added another...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9559
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9107
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7596
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4268
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3788
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2964
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.