INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Parameterized Update Query

Parameterized Update Query

(OP)
I have the following query:

CODE

Set cmd = server.createobject("ADODB.Command")
cmd.ActiveConnection = conHAR
cmd.CommandType = 1
cmd.CommandTimeout = 900

cmd.CommandText = _
    "UPDATE [Master] SET [firstname] = @firstname, " & _
    "[middlename] = @middlename, [lastname] = @lastname, " & _
    "[address1] = @address1, [address2] = @address2, " & _
    "[city] = @city, [state] = @state, " & _
    "[zip] = @zip, [email] = @email, " & _
    "[mobilephone] = @mobilephone, [homephone] = @homephone, " & _
    "[password] = @password, [dining] = @dining, [tablegames] = @tablegames, " & _
    "[onlinegaming] = @onlinegaming, [entertainment] = @entertainment, " & _
    "[slotplay] = @slotplay, [registered] = @registered, [entrydate] = @entrydate " & _
    "WHERE [playercardnum] = '" & playercardnum & "' AND " & _
    "[dateofbirth] = '" & dateofbirth & "'"

cmd.Parameters.Append cmd.CreateParameter("@firstname",202,1,30, request.form("firstname"))
cmd.Parameters.Append cmd.CreateParameter("@middlename",202,1,1, request.form("middlename"))
cmd.Parameters.Append cmd.CreateParameter("@lastname",202,1,30, request.form("lastname"))
cmd.Parameters.Append cmd.CreateParameter("@address1",202,1,50, request.form("address1"))
cmd.Parameters.Append cmd.CreateParameter("@address2",202,1,50, request.form("address2"))
cmd.Parameters.Append cmd.CreateParameter("@city",202,1,30, request.form("city"))
cmd.Parameters.Append cmd.CreateParameter("@state",202,1,2, request.form("state"))
cmd.Parameters.Append cmd.CreateParameter("@zip",202,1,10, request.form("zip"))
cmd.Parameters.Append cmd.CreateParameter("@email",202,1,50, request.form("email"))
cmd.Parameters.Append cmd.CreateParameter("@mobilephone",202,1,12, request.form("mobilephone"))
cmd.Parameters.Append cmd.CreateParameter("@homephone",202,1,12, request.form("homephone"))
cmd.Parameters.Append cmd.CreateParameter("@password",202,1,10, request.form("psd"))
cmd.Parameters.Append cmd.CreateParameter("@dining",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@tablegames",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@onlinegaming",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@entertainment",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@slotplay",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@registered",11,1,, 1)
cmd.Parameters.Append cmd.CreateParameter("@entrydate",135,1,, Now())

cmd.Execute

Set conHAR = Nothing 

I get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 19.

/_registered.asp, line 109

Basically on the Execute line it is erroring out. I have the same amount of parameters in the append as I do the UPDATE statement. Any help would be greatly appreciated.

Thanks.

Swi

RE: Parameterized Update Query

This generally occurs if a field name in the sql doesn't match the name in the database.

RE: Parameterized Update Query

It is much easier to spot errors in SQL queries if you print out the concatenated string before looking for the problems.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Parameterized Update Query

(OP)
Ok, took your advice and got it worked out.

However, when POSTING my checkbox values I keep getting a blank value even when checked.

I read somewhere that ASP will not pass a black checkbox value but even the ones that are checked are coming up blank.

Any ideas?

Thanks.

Swi

RE: Parameterized Update Query

(OP)
Here is some of the ASP page that has the checkboxes:

CODE

<div class="form-group">
      <label class="col-md-3 control-label"></label>
        <div class="col-sm-2 checkbox" style="padding-left:34px;">
            <input class="form-control styled check" type="checkbox" name="chkEntertainment" id="chkEntertainment" value="">
            <label for="chkEntertainment" style="color: white;">
                Entertainment
            </label>
        </div>
        <div class="col-sm-2 checkbox" style="padding-left:34px;">
            <input class="form-control styled check" type="checkbox" name="chkSlotPlay" id="chkSlotPlay" value="">
            <label for="chkSlotPlay" style="color: white;">
                Slot Play
            </label>
        </div>
        <div class="col-sm-2 checkbox" style="padding-left:34px;">
            <input class="form-control styled check" type="checkbox" name="chkAll" id="chkAll" value="">
            <label for="chkAll" style="color: white;">
                All
            </label>
        </div>
    </div> 

The form data is then POSTED to another ASP page that does the following:

CODE

if request.form("chkDining") = "" then
    cmd.Parameters.Append cmd.CreateParameter("@password",11,1,1, 0)
else
    cmd.Parameters.Append cmd.CreateParameter("@password",11,1,1, 1)
end if 

Issue is I always get an empty checkbox value not matter if I checked it or not.

Thanks.

Swi

RE: Parameterized Update Query

(OP)
Oops:

CODE

if request.form("chkDining") = "" then
    cmd.Parameters.Append cmd.CreateParameter("@dining",11,1,1, 0)
else
    cmd.Parameters.Append cmd.CreateParameter("@dining",11,1,1, 1)
end if 

Swi

RE: Parameterized Update Query

(OP)
Figured out that it is some type of issue with Bootstrap CSS.

awesome-bootstrap-checkbox.css is a library I have in my project.

If I take this off and a normal style checkbox is available everything comes across ok. If I style the checkbox with this CSS it does not work.

Anyone come across this before?

Swi

RE: Parameterized Update Query

I'm confused ... request.form("chkDining") will return the value of chkDining, and in your sample code, every checkbox has an empty string for a value:

<input class="form-control styled check" type="checkbox" name="chkSlotPlay" id="chkSlotPlay" value="">

So if request.form("chkDining") = "" then will always be true, regardless of whether the checkbox was checked or not.

RE: Parameterized Update Query

(OP)
Crap, thanks for the obvious. Totally missed that.

Swi

RE: Parameterized Update Query

Quote:

I read somewhere that ASP will not pass a black checkbox value

Not just ASP, unchecked checkboxes simply do not pass values to ANY kind of server side processing.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Parameterized Update Query

(OP)
Thanks.

Swi

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close