Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameterized Update Query 1

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,963
0
36
US
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
 
This generally occurs if a field name in the sql doesn't match the name in the database.
 
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
 
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
 
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
 
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
 
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
 
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:

[tt]<input class="form-control styled check" type="checkbox" name="chkSlotPlay" id="chkSlotPlay" [highlight #FCE94F]value=""[/highlight]>[/tt]

So if request.form("chkDining") = "" then will always be true, regardless of whether the checkbox was checked or not.
 
Crap, thanks for the obvious. Totally missed that.

Swi
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top