CBDL() in SQL string or MM_columnsStr??

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default CBDL() in SQL string or MM_columnsStr??

    We are using a page that both displays the values of a record and allows a user
    to update. What we want to do is display the value as currency but post it to
    SQL server as a number with out the "$" or ",".

    Someone suggested using CBDL()
    like this:
    <%
    SQL = "update dbo.MyTable set ... ,money1=" & CDbl(Request("money1)) &
    ",Field7 = ..."
    %>

    However, DW constructs the sql string in a less straight forward method.
    We are using Dreamweaver MX 2000. I need to figure out how to use CBDL() for
    the money fields that go into this sql string. Where in the code do do this???

    The Code to display the value looks like this:


    <input name="id="money1" type="text" class="tablefields" value="<%=val%>" >

    The code DW uses to construct the SQL statement looks like this:

    ' query string to execute
    MM_editQuery = ""
    %>
    <%
    ' *** Update Record: set variables

    If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <>
    "") Then

    MM_editConnection = MM_xnet_STRING
    MM_editTable = "dbo.Relo_Referrals"
    MM_editColumn = "ReferralID"
    MM_recordId = "" + Request.Form("MM_recordId") + ""
    MM_editRedirectUrl = "ref_update_monies.asp"
    MM_fieldsStr = "servaddress|value|servcity|value|Money1|value|Fie ld7|?. "
    MM_columnsStr = "ServAddress|',none,''|ServCity|',none,''Money1|?, none,
    "Field7|?."

    ' create the MM_fields and MM_columns arrays
    MM_fields = Split(MM_fieldsStr, "|")
    MM_columns = Split(MM_columnsStr, "|")

    ' set the form values
    For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
    Next

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

    End If
    %>
    <%
    ' *** Update Record: construct a sql update statement and execute it

    If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "")
    Then

    ' create the sql update statement
    MM_editQuery = "update " & MM_editTable & " set "
    For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
    MM_formVal = MM_emptyVal
    Else
    If (MM_altVal <> "") Then
    MM_formVal = MM_altVal
    ElseIf (MM_delim = "'") Then ' escape quotes
    MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
    Else
    MM_formVal = MM_delim + MM_formVal + MM_delim
    End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
    MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
    Next
    MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

    If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery

    'Output the SQL to the browser
    response.write(MM_editQuery) 'comment this line out when not needed.
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
    Response.Redirect(MM_editRedirectUrl)
    End If
    End If

    End If
    %>


    WasBigT Guest

  2. Similar Questions and Discussions

    1. Maintain query string and somehow auto refresh a pagewith that string intact
      I have a drill down where on page one the user selects criteria to narrow down the search for a speicific group of employees(like all hired between...
    2. #7056 [Com]: Setting string variables to value starting with '<' cause string to be empty.
      ID: 7056 Comment by: davidgjenkins at ntlworld dot com Reported By: tammy at synchronis dot com Status: Closed...
    3. string question: how to append x zeros to get fixed lenght string?
      "Bob Barrows" <reb_01501@yahoo.com> wrote in message news:uuhVv4mcDHA.656@tk2msftngp13.phx.gbl... newstring = Right("0000000" & i,8) ;-p
    4. Cannot create an object of type 'System.String[]' from its representation 'String[] Array'
      Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To...
    5. String question: Returning portion of string with words surrounding highlighted search term?
      I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string,...
  3. #2

    Default Re: CBDL() in SQL string or MM_columnsStr??

    To keep my life easy with DW I would get value from the DB, format it and then
    display it. And when it comes to updating I would use java in the JSP to take
    the value from the user and strip it back to a number. I would keep all the
    parsing in java or js before updating. ie, I get last name and firstname from
    two columns in a database but display them as Lastname, Firstname. When
    changes are made I use js to update the values of two hidden fields before
    submittal. Many ways to skin this cat.

    cutigerfan Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139