Skip to main content
Inspiring
September 23, 2006
Question

problem updating SQL bit field? No error, but isn't updating?

  • September 23, 2006
  • 1 reply
  • 415 views
Hi,

I used the DW Update wizard to create an Update form which updates one
field, a bit field in an SQL database table.
Problem is, it isn't changing the field value! The bit field is initially
"True" and I want to update it to be "False".

Here's the code:

<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" &
Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_connNAME_STRING
MM_editCmd.CommandText = "UPDATE dbo.tblOrders SET liveorder = ? WHERE
orderID = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5,
1, -1, MM_IIF(Request.Form("liveorder"), -1, 0)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5,
1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"),
null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "confirmdelete.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>

And this is the form that I'm using:

<form method="POST" action="<%=MM_editAction%>" name="form1">
<input type="hidden" name="liveorder" value=0 />
<input type="submit" value="Update record" />
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=
rsOrders.Fields.Item("orderID").Value %>">
</form>

The only thing I've changed is to make the "liveorder" form field hidden.
But even if I don't do that, it still doesn't work.
Hope someone can spot something I've obviously missed.

Regards
Nath.


This topic has been closed for replies.

1 reply

Inspiring
September 23, 2006
It appears that you can't use this:

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1,
MM_IIF(Request.Form("liveorder"), -1, 0)) ' adDouble

...with an SQL bit field. It has to be numeric, like this:

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1,
MM_IIF(Request.Form("liveorder"), Request.Form("liveorder"), null)) '
adDouble

..and it works! Weird!

Nath.

"tradmusic.com" <sales@NOSHPAMtradmusic.com> wrote in message
news:ef3bpq$kof$1@forums.macromedia.com...
> Hi,
>
> I used the DW Update wizard to create an Update form which updates one
> field, a bit field in an SQL database table.
> Problem is, it isn't changing the field value! The bit field is
> initially "True" and I want to update it to be "False".
>
> Here's the code:
>
> <%
> Dim MM_editAction
> MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
> If (Request.QueryString <> "") Then
> MM_editAction = MM_editAction & "?" &
> Server.HTMLEncode(Request.QueryString)
> End If
>
> ' boolean to abort record edit
> Dim MM_abortEdit
> MM_abortEdit = false
> %>
> <%
> ' IIf implementation
> Function MM_IIf(condition, ifTrue, ifFalse)
> If condition = "" Then
> MM_IIf = ifFalse
> Else
> MM_IIf = ifTrue
> End If
> End Function
> %>
> <%
> If (CStr(Request("MM_update")) = "form1") Then
> If (Not MM_abortEdit) Then
> ' execute the update
> Dim MM_editCmd
>
> Set MM_editCmd = Server.CreateObject ("ADODB.Command")
> MM_editCmd.ActiveConnection = MM_connNAME_STRING
> MM_editCmd.CommandText = "UPDATE dbo.tblOrders SET liveorder = ? WHERE
> orderID = ?"
> MM_editCmd.Prepared = true
> MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5,
> 1, -1, MM_IIF(Request.Form("liveorder"), -1, 0)) ' adDouble
> MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5,
> 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"),
> null)) ' adDouble
> MM_editCmd.Execute
> MM_editCmd.ActiveConnection.Close
>
> ' append the query string to the redirect URL
> Dim MM_editRedirectUrl
> MM_editRedirectUrl = "confirmdelete.asp"
> If (Request.QueryString <> "") Then
> If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
> MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
> Else
> MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
> End If
> End If
> Response.Redirect(MM_editRedirectUrl)
> End If
> End If
> %>
>
> And this is the form that I'm using:
>
> <form method="POST" action="<%=MM_editAction%>" name="form1">
> <input type="hidden" name="liveorder" value=0 />
> <input type="submit" value="Update record" />
> <input type="hidden" name="MM_update" value="form1">
> <input type="hidden" name="MM_recordId" value="<%=
> rsOrders.Fields.Item("orderID").Value %>">
> </form>
>
> The only thing I've changed is to make the "liveorder" form field hidden.
> But even if I don't do that, it still doesn't work.
> Hope someone can spot something I've obviously missed.
>
> Regards
> Nath.
>