If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Help required updating SQL db

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-04, 07:41
kev_gilmour kev_gilmour is offline
Registered User
 
Join Date: May 2004
Location: Glasgow, Scotland
Posts: 2
Angry 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
Reply With Quote
  #2 (permalink)  
Old 05-14-04, 14:26
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
  #3 (permalink)  
Old 05-17-04, 04:26
kev_gilmour kev_gilmour is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 05-17-04, 11:25
Seppuku Seppuku is offline
Useless...
 
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
%>
__________________
That which does not kill me postpones the inevitable.

Last edited by Seppuku; 05-17-04 at 12:38.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On