Re: display limited records
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Tue, 15 May 2007 07:08:50 -0400
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"
.
- References:
- ADO: display limited records
- From: saxenavaibhav17
- ADO: display limited records
- Prev by Date: Re: Add/Update database with ADO Data control
- Next by Date: Re: Need help with cinema system
- Previous by thread: ADO: display limited records
- Next by thread: Need help with cinema system
- Index(es):
Relevant Pages
|
|