close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

DataAssist inserts two records (sometimes)

Thread began 9/02/2009 11:18 am by markdoyle87077 | Last modified 2/18/2010 10:03 am by georgina_barrett_187762 | 1793 views | 4 replies |

markdoyle87077

DataAssist inserts two records (sometimes)

I have some registration pages that have been working fine but I recently changed the validation to Spry from WA Validation Toolkit and now sometimes the WA DataAssist Insert Record Behaviour inserts two records into my SQL table. The first record is the registration information from the registration page and the second record inserts with some of the information. Could you kindly look at the attached pages for me as I am cannot resolve this issue. Thank you.

Attached Files
registration.zip
Sign in to reply to this post

Jason ByrnesWebAssist

The trigger for the insert is if the recordset is empty. the recordset is filtered on the email address from element, so the recordset will be empty any tinme this page is accessed directly:

<%
' WA Application Builder Insert
if ((rsCheckUsername.EOF AND rsCheckUsername.BOF)) then
WA_connection = MM_dmballoo_sql_STRING
WA_table = "dbo.userdetails"
WA_sessionName = "userdetails_id"
WA_redirectURL = ""
WA_keepQueryString = false
WA_indexField = "id"
WA_fieldNamesStr = "firstname|surname|emailaddress|password|telephonenumber|discount|newsletter|language|active"
WA_fieldValuesStr = "" & cStr(cStr(Request.Form("firstname"))) & "" & "|" & "" & cStr(cStr(Request.Form("surname"))) & "" & "|" & "" & cStr(cStr(Request.Form("emailaddress"))) & "" & "|" & "" & cStr(cStr(Request.Form("password"))) & "" & "|" & "" & cStr(cStr(Request.Form("telephonenumber"))) & "" & "|" & "" & cStr(cStr(Request.Form("discount"))) & "" & "|" & "Yes" & "|" & "German" & "|" & "No"
WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''"
WA_comparisonStr = " LIKE | LIKE | LIKE | LIKE | LIKE | = | LIKE | LIKE | LIKE "
WA_fieldNames = Split(WA_fieldNamesStr,"|")
WA_fieldValues = Split(WA_fieldValuesStr,"|")
WA_columns = Split(WA_columnTypesStr,"|")
WA_comparisions = Split(WA_comparisonStr, "|")

insertParamsObj = WA_AB_generateInsertParams(WA_fieldNames, WA_columns, WA_fieldValues, -1)
set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = WA_connection
MM_editCmd.CommandText = "INSERT INTO " & WA_table & " (" & insertParamsObj(1) & ") VALUES (" & insertParamsObj(2) & ")"
MM_editCmd.Execute()
MM_editCmd.ActiveConnection.Close()
obj = WA_AB_generateWhereClause(WA_fieldNames, WA_columns, WA_fieldValues, WA_comparisions)
sqlstr = "SELECT " & WA_indexField & " FROM " & WA_table & " WHERE " & obj & " ORDER BY " & WA_indexField & " DESC"
set WA_AppBuilderRecordset = Server.CreateObject("ADODB.Recordset")
WA_AppBuilderRecordset.ActiveConnection = WA_connection
WA_AppBuilderRecordset.Source = sqlstr
WA_AppBuilderRecordset.CursorType = 0
WA_AppBuilderRecordset.CursorLocation = 2
WA_AppBuilderRecordset.LockType = 1
WA_AppBuilderRecordset.Open()
if (NOT WA_AppBuilderRecordset.EOF) then Session(WA_sessionName) = WA_AppBuilderRecordset.Fields.Item(WA_indexField).Value
WA_AppBuilderRecordset.Close()
if (WA_redirectURL <> "") then
if (WA_keepQueryString AND Request.QueryString <> "" AND Request.QueryString.Count > 0) then
if (inStr(WA_redirectURL,"?") > 0) then
WA_redirectURL = WA_redirectURL & "&"
else
WA_redirectURL = WA_redirectURL & "?"
end if
WA_redirectURL = WA_redirectURL & Request.QueryString
end if
Response.Redirect(WA_redirectURL)
end if
end if
%>





Add another If around the insert so the insert will only occur if an email address was posted to the page, and it was not found in the database:

<% If (Request.Form("emailaddress") <> "") Then %>
<%
' WA Application Builder Insert
if ((rsCheckUsername.EOF AND rsCheckUsername.BOF)) then
WA_connection = MM_dmballoo_sql_STRING
WA_table = "dbo.userdetails"
WA_sessionName = "userdetails_id"
WA_redirectURL = ""
WA_keepQueryString = false
WA_indexField = "id"
WA_fieldNamesStr = "firstname|surname|emailaddress|password|telephonenumber|discount|newsletter|language|active"
WA_fieldValuesStr = "" & cStr(cStr(Request.Form("firstname"))) & "" & "|" & "" & cStr(cStr(Request.Form("surname"))) & "" & "|" & "" & cStr(cStr(Request.Form("emailaddress"))) & "" & "|" & "" & cStr(cStr(Request.Form("password"))) & "" & "|" & "" & cStr(cStr(Request.Form("telephonenumber"))) & "" & "|" & "" & cStr(cStr(Request.Form("discount"))) & "" & "|" & "Yes" & "|" & "German" & "|" & "No"
WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''"
WA_comparisonStr = " LIKE | LIKE | LIKE | LIKE | LIKE | = | LIKE | LIKE | LIKE "
WA_fieldNames = Split(WA_fieldNamesStr,"|")
WA_fieldValues = Split(WA_fieldValuesStr,"|")
WA_columns = Split(WA_columnTypesStr,"|")
WA_comparisions = Split(WA_comparisonStr, "|")

insertParamsObj = WA_AB_generateInsertParams(WA_fieldNames, WA_columns, WA_fieldValues, -1)
set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = WA_connection
MM_editCmd.CommandText = "INSERT INTO " & WA_table & " (" & insertParamsObj(1) & ") VALUES (" & insertParamsObj(2) & ")"
MM_editCmd.Execute()
MM_editCmd.ActiveConnection.Close()
obj = WA_AB_generateWhereClause(WA_fieldNames, WA_columns, WA_fieldValues, WA_comparisions)
sqlstr = "SELECT " & WA_indexField & " FROM " & WA_table & " WHERE " & obj & " ORDER BY " & WA_indexField & " DESC"
set WA_AppBuilderRecordset = Server.CreateObject("ADODB.Recordset")
WA_AppBuilderRecordset.ActiveConnection = WA_connection
WA_AppBuilderRecordset.Source = sqlstr
WA_AppBuilderRecordset.CursorType = 0
WA_AppBuilderRecordset.CursorLocation = 2
WA_AppBuilderRecordset.LockType = 1
WA_AppBuilderRecordset.Open()
if (NOT WA_AppBuilderRecordset.EOF) then Session(WA_sessionName) = WA_AppBuilderRecordset.Fields.Item(WA_indexField).Value
WA_AppBuilderRecordset.Close()
if (WA_redirectURL <> "") then
if (WA_keepQueryString AND Request.QueryString <> "" AND Request.QueryString.Count > 0) then
if (inStr(WA_redirectURL,"?") > 0) then
WA_redirectURL = WA_redirectURL & "&"
else
WA_redirectURL = WA_redirectURL & "?"
end if
WA_redirectURL = WA_redirectURL & Request.QueryString
end if
Response.Redirect(WA_redirectURL)
end if
end if
%>
<% End If %>
Sign in to reply to this post

markdoyle87077

Thank

Many thanks for another speedy resolution.

Sign in to reply to this post

Jason ByrnesWebAssist

You're welcome.

Sign in to reply to this post

georgina_barrett_187762

I have solved it I changed if (isset($_POST["Insert_x"])) // Trigger to a field in that table.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...