Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Code not erroring, but also not posting to database
Old 10-23-2006, 10:02 AM Code not erroring, but also not posting to database
Novice Talker

Posts: 14
Trades: 0
Hey Everyone,
I have an interesting problem. I have a standard form of information that needs to be submitted to a database. When the form is filled out and the 'submit' button is clicked it goes to the 'thank you' page, but nothing is sent into the database...and I get no errors. I also have the form data being sent by smtp mail to a number of people. The emailing part does work.

Any help or suggestions would be great. The code is posted below - I've removed some code from the email portion of the work below for security reasons:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/cbleConn.asp" -->
<!--#include file="../Includes/adovbs.inc" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

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

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
MM_dupKeyRedirect="userexists.asp"
MM_rsKeyConnection=MM_cbleConn_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("Email"))
MM_dupKeySQL="SELECT Email FROM cble_db WHERE Email='" & MM_dupKeyUsernameValue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "cble_register") Then

MM_editConnection = MM_cbleConn_STRING
MM_editTable = "cble_db"
MM_editRedirectUrl = "thankyou.asp"
MM_fieldsStr = "Contact|value|Company|value|Phone|value|Email|val ue|Pwd|value|CurrentCustomer|value|dtStamp|value"
MM_columnsStr = "Contact|',none,''|Company|',none,''|Phone|',none, ''|Email|',none,''|Pwd|',none,''|CurrentCustomer|' ,none,''|dtStamp|',none,NULL"

' 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
%>

<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

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

'SEND MAIL to registrant
///code omitted for security reasons///

If Mailer.SendMail then
'Message sent sucessfully
else
'Message send failure
response.write ("Your message was not sent. ")
response.write ("The error was: " & Mailer.Response)
end if

Set Mailer=nothing

'SEND MAIL to cblesupport
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "localhost"
If request("Contact") > "" Then
Mailer.FromName = request("Contact")
Else

If Mailer.SendMail then
'Message sent sucessfully
else
'Message send failure
response.write ("Your message was not sent. ")
response.write ("The error was: " & Mailer.Response)
end if

If (MM_editRedirectUrl <> "") Then
session("SVconfirm") = request.form("Email")
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
ucmeicu is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-23-2006, 12:43 PM Re: Code not erroring, but also not posting to database
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Oh God. Dr*amw*av*r ASP code again. *shudders*

The only thing I could see that would stop the code from inserting a table record and NOT throwing an error would be if mm_abortEdit somehow became true at some point.

What I would do is try Response.Write MM_abortEdit & "<br />" at various points, to see where (if anywhere) MM_abortEdit becomes true.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Code not erroring, but also not posting to database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10868 seconds with 12 queries