Re: display limited records



saxenavaibhav17@xxxxxxxxx wrote:
Hi all;
qrymillcgetbytype_app ( stored query in MS-Access) in my code :
C++ PART
bstrSQL contain stored query name "qrymillcgetbytype_app"

That's all it contains? What about the parameter value? Are you using the
EXEC or call keyword in this bstrSQL string?

hr = piRecordSet->put_Source(bstrSQL);
piRecordSet->Open(vNull, vNull, adOpenKeyset, adLockOptimistic,
adCmdUnknown)

Avoid adCmdUnknown. You know what the command type is. Tell ADO. Don't make
it guess.

In this case, given the lack of information about bstrSQL, I am not sure
what the command type is. If all it contains is the name of the saved query,
then your command type should probably be adCmdStoredProc and you should be
using the Parameters collection to pass the parameter value to it.

If. OTOH, it contains something like "EXEC qrymillcgetbytype_app 23", then
the command type is adCmdText.

it opens fine
but when bstrSQL contain this query name " qrymillcgetbytype_app
WHERE ID > -1 AND [Tool Dia] >= 0.000000 AND [Tool Dia] <= 5.000000 "

it displays the same output. Where clause won't work?
Pls help me out.

You will need to use a full sql statement using the saved query in the FROM
clause:

"select ... FROM qrymillcgetbytype_app WHERE ... "

And, you will need to use an explicit Command object to pass the parameter
value to the saved query. I don't do C++ but here is the equivalent vbscript
code:

const adInteger=3
const adParamInput=1
bstrSQL="select ... FROM qrymillcgetbytype_app WHERE ... "
parval=23 'for example
set cmd=new adodb.command
cmd.commandtext = bstrSQL
cmd.commandtype=1 'adCmdText
cmd.Parameters.Append cmd.CreateParameter("parm", _
adInteger,adParamInput,,parmval)
set cmd.activeconnection = <open connection object>
set piRecordSet = new adodb.recordset
piRecordSet.Open ,cmd,adOpenKeyset, adLockOptimistic



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: Export Subform results to EXCEL
    ... A QueryDef object is a code structure that represents a query that is ... stored in an Access database. ... but it is not the same thing as the stored query. ...
    (microsoft.public.access.formscoding)
  • Re: opening same kind of recordset gives error for one while not f
    ... I just checked the stored query GMISExpenseCombo1 and did not find any ... Since I cannot post the QBE format of the stored ... >> first recordset, I do not get an erro while for the second recordset, ...
    (microsoft.public.inetserver.asp.db)
  • Re: bind listbox to parameterized query?
    ... Have you tried creating a stored query that uses the parameter? ... set the listbox's Row Source Type to Table/Query and the Row Source ... You will need to requery the listbox whenever the value ...
    (microsoft.public.access.formscoding)
  • Re: Running MSAccess Query thru ADO
    ... When you run Access query from VB, using Jet the provider puts some ... Could be same problem with the pivot syntax. ... problem you could put your SQL statement into Access stored query and call ...
    (microsoft.public.data.ado)
  • Re: Pass parameter to stored query
    ... The stored query has a parameter named "Project Number" ... .CommandText = SQLstr ... dim prm as adodb.parameter ...
    (microsoft.public.access.formscoding)