I have a subroutine in my asp file, I am trying to add to a database table.
When I remove the subroutine wrapper from the logic, it works. (but of course, submits automatically before any user interaction).
I have tested this backwards and forwards and I cannot for the life of me see why this is happening. I've added logic to prevent the data being able to be submitted if the fields values are empty, or the button hasn't been pressed.
Any help would be hugely appreciated.. must admit this one is driving me bonkers, as I'm copying it from another routine I wrote on another page that is working perfectly.
Thanks.
<% Dim objConn, connStr, strSql
Dim iCommandID
Dim strUserName, strEmailAddress, strPassword1, bSubmit
iCommandID = Request.Form("cmdID")
strUserName = CStr(Request.Form("username"))
strEmailAddress = CStr(Request.Form("emailAddress"))
strPassword1 = CStr(Request.form("password1"))
bSubmit = Request.Form("btnSubmit")
If Request.Form("cmdID").Count > 0 Then
iCommandID = CLng(Request.Form("cmdID"))
ElseIf Request.QueryString("cmdID").Count > 0 Then
iCommandID = Clng(Request.QueryString("cmdID"))
Else
iCommandID = 0
End If
response.write(iCommandID)
SELECT CASE iCommandID
CASE 1
addUser
END SELECT
Sub addUser
If bSubmit <> "" Then
If strUserName <> "" AND strEmailAddress <> "" AND strPassword1 <> "" Then
connStr = Application("DATABASE_CONNECTION_STRING")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open(connStr)
strSql = "INSERT INTO dbo.tbl_Users (userName, userEmailAdd, userPassHash) VALUES (" + "'" + strUserName + "'," + "'" + strEmailAddress + "'," + "'" + strPassword1 + "'" + ")"
objConn.Execute strSql, , adCmdText
objConn.Close
Set objConn = Nothing
End If
End If
End Sub
%> ```
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…