Click to See Complete Forum and Search --> : Recordset Shaping


Spectre5000
August 21st, 2001, 12:00 PM
I am having some difficulty with an ADO query selection thing. I have 3 queries that I am currently running to
retrieve information on 1 client. What I want to do is to use an ADODC data control that will combine all of
the information into 1 shape statement, so I can just cycle through the records and display all of the pertinent
information for each client. Here is how I am currently accessing the information:



dim oConn as new adodb.connection
dim rsname as new adodb.recordset
dim rsclient as new adodb.recordset
dim rsphone as new adodb.recordset

dim lngcurrentclientid as long

dim strquery as string

oconn.connectionstring = "dsn=Martins SQL"
oconn.open

strquery = "select * from name order by nameid"
rsname.open strquery, oconn, adopendynamic, adlockoptimistic
rsname.movefirst
lngcurrentclientid = rsname!nameid

strquery = "select * from client where clientid = " & lngcurrentclientid
rsclient.open strquery, oconn, adopendynamic, adlockoptimistic

strquery = "select * from phone where clientid = " & lngcurrentclientid
rsphone.open strquery, oconn, adopendynamic, adlockoptimistic





Now, this is kinda effective, but I have to repeat this process every time I move through the recordset. I read
something about using the SHAPE command as part of the SQL statement, so I built a smaller version of our
client maintenance form and used an ADO data control. The shape statement I am using is:

SHAPE ( SHAPE {SELECT * FROM Name ORDER BY NameID}
APPEND (( SHAPE {SELECT * FROM Client ORDER BY ClientID}
APPEND ({SELECT * FROM Phone ORDER BY ClientID,Sequence}
RELATE ClientID TO ClientID) AS rsPhone)
RELATE NameID TO ClientID) AS rsClient)
AS rsName

In the form)load event, I set DataGrid1.dataSource = adodc1.recordset("rsClient").UnderlyingValue, and I set
DataGrid2.dataSource = adodc1.recordset("rsPhone").UnderlyingValue. However, when I run this I get the error:

Run-Time Error '3265':

Item cannot be found in the collection corresponding to the requested name or ordinal.

I hit debug, and it brings me to the datagrid2.datasource line, so I am assuming that this has to do with the child
recordset rsPhone. My question:

Does anyone know how I can fix this? How do I use the shape command so I am retrieving all of the name, client, and
phone information for each client (the client table stores demographics like sex and birthdate)? The VB data wizard form
only allows 1 master record and 1 detail record, so any help anyone has would be much appreciated. How can I get
all of this information using just 1 ado data control with the shape statement?

ps - I need this so badly that I would be willing to part with a $10.00 or $20.00 money order to the first person to get me
a CORRECT and WORKING answer!