Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Location
    Glasgow, Scotland
    Posts
    2

    Angry Unanswered: Help required updating SQL db

    Hi there using Microsoft Commerce Server and I'm new to SQL and development so I'm hoping someone here might be able to help me.

    I'm trying to customize my 'product_new.asp' page to include my own additional fields which will be posted into my SQL db.

    My form is populated with 2 types of fields...text boxes and check boxes.

    <INPUT TYPE="text" SIZE="32" NAME="name" VALUE="<%= Request("name") %>" onChange="dirty = true"><input type="checkbox" name="web_publish" value="<%= Request("web_publish") %>" onChange="dirty = true" checked>

    I've been trying to use the following code to update the fields in the db.

    cmdTemp.CommandText = Replace("SELECT * FROM store_product WHERE pf_id = ?", "?", "'" & Replace(Request("pf_id"),"'","''") & "'")
    Set rsProduct = Server.CreateObject("ADODB.Recordset")
    rsProduct.Open cmdTemp, , adOpenStatic, adLockOptimistic
    rsProduct.AddNew
    rsProduct("pf_id").value = pf_id
    rsProduct("name").Value = mscsPage.RequestString("name", "", 1, 255)
    rsProduct("web_publish").Value = mscsPage.RequestNumber("web_publish", "", 1, 255)
    rsProduct.Update

    The properties for the 'web_publish' field in SQL is set as a small (one byte) integer field.

    The 'name' value works okay... 'web_publish' does not. I really don't know what I'm doing someone please help! I hope all of this makes sense to you.

    Thanks.

    KEV

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    What do you mean by "The 'name' value works okay... 'web_publish' does not"? Can you expound upon that? What's the expected result, and what is it doing you don't want it to do?

    Second, you don't need to do that Replace. You can leave the question marks if you use parameters in your command object. It's a safer way to go.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    May 2004
    Location
    Glasgow, Scotland
    Posts
    2
    Quote Originally Posted by Seppuku
    What do you mean by "The 'name' value works okay... 'web_publish' does not"? Can you expound upon that? What's the expected result, and what is it doing you don't want it to do?
    Sorry Seppuku if I didn't make myself clear enough...like I said this stuff is all pretty new to me.

    All I meant was that any values I place in my text fields (e.g. 'name') insert into my recordset on the SQL db okay, however the values of my checkboxes do not.

    I want to add and append product records to my SQL database but it just won't accept any checkbox values.

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    What kind of value are you expecting from the checkbox? When I read a checkbox in ASP, I simply check to see if it's checked or not. I never set a value in the <input type="checkbox" name="myCheckbox"> HTML tag itself.

    <%
    Dim cbValue
    If Request.Form("myCheckbox") = "on" Then
    cbValue = True
    Else
    cbValue = False
    End If
    %>
    Last edited by Seppuku; 05-17-04 at 13:38.
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •