Ask a Question related to ASP Database, Design and Development.
-
Chopper #1
SPs/Command Object/Parameters Problem
I've searched through google groups and cannot find an answer to this:
My application passes values from a form to a page that requests them and
sets them as parameters which are then passed to the SP. The SP then updates
a table with these values.
The problem is that not all of the values need to be entered on the form and
therefore there can be empty parameters being passed to the stored
procedure.
In the SP I've made sure all the default values are set so there is no
problem there but it's the calling of the SP with empty parameters that is
causing problems.
What would be ideal is if I could conditionally pass parameters, e.g.:
if varTitle <> "" then
.Parameters.Append
..CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)
end if
But this gives errors.
Please can anyone tell me if there is a way of doing this or if I am doing
something wrong? I understand I could dynamically build and execute an
update query in ASP but would prefer to use SPs as everything else uses
them.
TIA
chopper
Chopper Guest
-
get command line parameters in plugin (i.e. argc & argv)
hi, i'm searching in the api documentation how to get parameters passed to acrobat when i call c:\acrobat\acrobat.exe ___mypdf.pdf -C ashjs7... -
using Command to set Parameters and Recordset to retrive the Query
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under... -
Projector with command line parameters
Hello, is it possible to build a projector, which can be started with command line parameters? If yes, how can I get access to this parameters... -
Command Parameters
Can someone tell me why the following code does not work ? It does not crash or cause errors and it creates a new row in the table "tblusers" but... -
Passing parameters to a Perl Script from Command Line (Linux)
Hi, I'm fairly new to both programming in shell script (linux) and in programming in perl. I need to pass a parameter to the perl script from... -
Bob Barrows #2
Re: SPs/Command Object/Parameters Problem
Pass the missing values as Nulls. Instead of this:
..CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)> if varTitle <> "" then
> .Parameters.Append
>You want to do this:> end if
if varTitle = "" then
varTitle = Null
end if
.Parameters.Append
..CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)
Do you really need a Command object? If your SP doesn't have any output
parameters and you're not interested in evaluating the Return value, then
you don't need a Command object. You can use the
stored-procedure-as-connection-method technique. A quick Google search
should provide details.
HTH,
Bob Barrows
Chopper wrote:..CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)> I've searched through google groups and cannot find an answer to this:
> My application passes values from a form to a page that requests them
> and sets them as parameters which are then passed to the SP. The SP
> then updates a table with these values.
>
> The problem is that not all of the values need to be entered on the
> form and therefore there can be empty parameters being passed to the
> stored procedure.
> In the SP I've made sure all the default values are set so there is no
> problem there but it's the calling of the SP with empty parameters
> that is causing problems.
>
> What would be ideal is if I could conditionally pass parameters, e.g.:
> if varTitle <> "" then
> .Parameters.Append
>> end if
>
> But this gives errors.
>
> Please can anyone tell me if there is a way of doing this or if I am
> doing something wrong? I understand I could dynamically build and
> execute an update query in ASP but would prefer to use SPs as
> everything else uses them.
>
> TIA
>
> chopper
Bob Barrows Guest
-
Chopper #3
Re: SPs/Command Object/Parameters Problem
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OeZsNRljDHA.2140@TK2MSFTNGP09.phx.gbl.....CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)> Pass the missing values as Nulls. Instead of this:>> > if varTitle <> "" then
> > .Parameters.Append
> >..CreateParameter("@title",adLongVarChar,adParamIn put,len(varTitle),varTitle)>> > end if
> You want to do this:
> if varTitle = "" then
> varTitle = Null
> end if
> .Parameters.Append
>Thanks for your reply.>
> Do you really need a Command object? If your SP doesn't have any output
> parameters and you're not interested in evaluating the Return value, then
> you don't need a Command object. You can use the
> stored-procedure-as-connection-method technique. A quick Google search
> should provide details.
>
> HTH,
> Bob Barrows
>
I get a type mismatch error when creating the parameter when the argument is
null :(
Are you sure null is a valid argument with the adLongVarChar type?
chopper
Chopper Guest
-
Bob Barrows #4
Re: SPs/Command Object/Parameters Problem
Chopper wrote:
Oh, my bad. I did not read closely enough.>
> Thanks for your reply.
> I get a type mismatch error when creating the parameter when the
> argument is null :(
> Are you sure null is a valid argument with the adLongVarChar type?
>
> chopper
With a string parameter, there should be no problem passing an empty string.
You do need to make sure your variable contains an empty string (and isn't
simply empty). You can use CStr to guarantee that.
With number or datetime types, I have found the need to set the values to
Null when values were not supplied by the user.
Bob Barrows
Bob Barrows Guest
-
Chopper #5
Re: SPs/Command Object/Parameters Problem
<snip>
string.> With a string parameter, there should be no problem passing an emptyThat did it!> You do need to make sure your variable contains an empty string (and isn't
> simply empty). You can use CStr to guarantee that.
>
> With number or datetime types, I have found the need to set the values to
> Null when values were not supplied by the user.
>
> Bob Barrows
>
>
Many thanks for your help.
Chopper Guest



Reply With Quote

