stored proc from classic asp and ado parameter issue

stored proc from classic asp and ado parameter issue

am 17.03.2005 16:05:05 von gorostasREMOVE_THIS

Hi all,

i have one asp page which picks up about 15 number values from form, and
enters it into sql server database whit float data type fiels.
my problem is how to enter NULL value into database if nothing is entered
into form, and not '0'.

i have this code which doesnt work well..
----
Set con = Server.CreateObject("ADODB.Connection")
con.open "Provider=SQLOLEDB.1;Integrated Security=SSPI" & _
";Persist Security Info=False;Initial Catalog=kandidati1;" & _
"Data Source=mvp525\NETSDK"
Set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = con

cm.CommandType = adCmdStoredProc
cm.CommandText = "edit_test"
cm.NamedParameters = True

cm.Parameters.Append cm.CreateParameter("@id", 200, 1, 4,
request.form("oop"))
cm.Parameters.Append cm.CreateParameter("@t1", 200, 1, 8,
request.form("test1"))
cm.Parameters.Append cm.CreateParameter("@t2", 200, 1, 8,
request.form("test2"))
cm.Parameters.Append cm.CreateParameter("@t3", 200, 1, 8,
request.form("test3"))
cm.Parameters.Append cm.CreateParameter("@t4", 200, 1, 8,
request.form("test4"))
cm.Parameters.Append cm.CreateParameter("@t5", 200, 1, 8,
request.form("test5"))
cm.Parameters.Append cm.CreateParameter("@t6", 200, 1, 8,
request.form("test6"))
cm.Parameters.Append cm.CreateParameter("@t7", 200, 1, 8,
request.form("test7"))
cm.Parameters.Append cm.CreateParameter("@t8", 200, 1, 8,
request.form("test8"))
cm.Parameters.Append cm.CreateParameter("@t9", 200, 1, 8,
request.form("test9"))
cm.Parameters.Append cm.CreateParameter("@t10", 200, 1, 8,
request.form("test10"))
cm.Parameters.Append cm.CreateParameter("@t11", 200, 1, 8,
request.form("test11"))
cm.Parameters.Append cm.CreateParameter("@t12", 200, 1, 8,
request.form("test12"))
cm.Parameters.Append cm.CreateParameter("@t13", 200, 1, 8,
request.form("test13"))
cm.Parameters.Append cm.CreateParameter("@t14", 200, 1, 8,
request.form("test14"))
cm.Parameters.Append cm.CreateParameter("@t15", 200, 1, 8,
request.form("test15"))

cm.Execute

----
and my idea was this...to remove this big block of code and make some nice
do loop function.., but i got server error page #500 internal error...or
whitout friendly HTTP error msg in internet explorer, i got "loop whit out
do..??" - WHY?
----
dim j,f,e
j=0

do until j>=16
f="@t" & j+1
e="test" & j+1
if request.form(e)="" then
cm.Parameters.Append cm.CreateParameter(f, 200, 1, 8, NULL)
else
cm.Parameters.Append cm.CreateParameter(f, 200, 1, 8, request.form(e))
j=j+1
loop

-----------

if someone can help i would be very gratefull.
thanks in advance.


--
-k.p.

Re: stored proc from classic asp and ado parameter issue

am 17.03.2005 17:31:32 von reb01501

gorostas wrote:

> error...or whitout friendly HTTP error msg in internet explorer, i
> got "loop whit out do..??" - WHY?
> ----
> dim j,f,e
> j=0
>
> do until j>=16
> f="@t" & j+1
> e="test" & j+1
> if request.form(e)="" then
> cm.Parameters.Append cm.CreateParameter(f, 200, 1, 8, NULL)
> else
> cm.Parameters.Append cm.CreateParameter(f, 200, 1, 8, request.form(e))

You're missing the "end if" statement here. Yes, I know the error message is
misleading. Here is what happened:
It started your loop at the Do statement. It then reached the If statement
where it started an "If" block. Since it never executes an "end if"
statement, it thinks it's still inside the "If" block when it reaches the
"loop" statement. Since you never began a loop inside the "If" block, it
raised the "loop without do" error and quit. Is that clear? Your "If" block
is nested within the "Do" block. You have to terminate nested (inner) blocks
before terminating outer blocks.

> j=j+1
> loop
>
> -----------
>
> if someone can help i would be very gratefull.
> thanks in advance.
>

Why have you ignored the other advice I gave you in the .vbscript newsgroup?
You really don't have to go to all this trouble.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.