Ask a Question related to Dreamweaver AppDev, Design and Development.
-
WasBigT #1
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
-
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... -
#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... -
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 -
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... -
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,... -
cutigerfan #2
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



Reply With Quote

