PDA

Click to See Complete Forum and Search --> : Query on ADO Recordset


hi_vijay
Feb 16th, 2000, 10:23 PM
Hi,

I have a ADO recordset object which retreive data from database. now I want to run queries on that recordset. Is it possible to do this? if Yes, send me details. or any other alternative if anybody know (Momory Tables etc.)

Thanks.

DatabaseLife
Feb 16th, 2000, 10:43 PM
Put a DataGrid on the form and connect it to the ADO control.

Make a button.

In the click event, simply type

Command1_Click()

Dim SomeVariable as String
SomeVariable = "Patrick"

Adodc1.DataSource="Select * FROM YourTable WHERE FirstName = '" & SomeVariable & "'"

Adodc1.Refresh

End Sub

Your DataGrid (eg. MSHFlex) should dynamically change and return all 'Patricks' in your 'FirstName' column

This works pretty consistently with adClient cursors, but with adServer cursors this may cause premature baldness.

Clunietp
Feb 17th, 2000, 12:38 AM
No, no built-in function in an ADO RS... you'll need to requery the DB for the SUM (the best & fastest way) or do it manually on the client

Tonatiuh
Feb 17th, 2000, 11:44 AM
I'm using an ODBC DSN to connect to the database. Is there any way to connect a DataGrid or a FlexiGrid to a recordset without any datacontrol?

Thanks!

Clunietp
Feb 17th, 2000, 11:45 AM
I believe you can set the FlexGrid.Recordsource to a recordset object at runtime.....

hi_vijay
Feb 17th, 2000, 11:48 AM
Thanks for reply.
Actually, The query which your are sayinhg will again goto Database to retrieve data. Let me explain problem again.

Suppose, I have a recordset(Unbound mode : NOT bound to any database) which is filled with EmpNo, DeptNo, Salary by (Select * From EMP) query. Now I want to make summation of Salary.
I don't want to Parse each and every record to get the Sum(Salary).
( Result simmilar to query
Select SUM(Salary) from Emp )

One way is I will declare a variable, use MoveNext method till EOF and add salary in variables . But this will be take more time records in thousands. Now is there any in build function of ADO which will directly give me Summation of fields.



[This message has been edited by hi_vijay (edited 02-17-2000).]