madanthrax
IS-IT--Management
Hi all,
I use Dreamweaver for html and css but nowadays like to write my own asp code (as advised in this forum). However I use an asp upload script which was sold as a DW extension. I have adapted it a lot to suit my needs, rewriting most of the silly DW asp code surrounding it. Now there is a new faster version so I fired up DW8 and using the new extension made a box standard upload then insert form to SQL DB page using the wizard to give me some code to pick to pieces and update the required parts of my applications.
While doing the dissection I noticed DW8 uses very different insert method to the older versions. Now I always clean up the form variables before putting them in an SQL insert statement, such as replacing single quotes with ' and replacing semicolons and amphersands etc. (I do this and much more since a visit from a professional web security firm who came in and demonstrated how to SQL inject all our apps...gulp)
Below is the DW insert code. Can anyone tell me please whats going on here? The parameter stuff is all new to me. I recognise the last numbers at the end refer to the DB character limit, 500, 300, 1000 etc. but what are the 201 and 1 numbers for? Is there any checking of the input going on at all? Or is this a cool way to insert data?
By the way, in case its important, the MM_IIF Function (located above the above code) is:
Thanks for any help.
Anthony.
I use Dreamweaver for html and css but nowadays like to write my own asp code (as advised in this forum). However I use an asp upload script which was sold as a DW extension. I have adapted it a lot to suit my needs, rewriting most of the silly DW asp code surrounding it. Now there is a new faster version so I fired up DW8 and using the new extension made a box standard upload then insert form to SQL DB page using the wizard to give me some code to pick to pieces and update the required parts of my applications.
While doing the dissection I noticed DW8 uses very different insert method to the older versions. Now I always clean up the form variables before putting them in an SQL insert statement, such as replacing single quotes with ' and replacing semicolons and amphersands etc. (I do this and much more since a visit from a professional web security firm who came in and demonstrated how to SQL inject all our apps...gulp)
Below is the DW insert code. Can anyone tell me please whats going on here? The parameter stuff is all new to me. I recognise the last numbers at the end refer to the DB character limit, 500, 300, 1000 etc. but what are the 201 and 1 numbers for? Is there any checking of the input going on at all? Or is this a cool way to insert data?
Code:
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_NSfiles_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.tbl_"& appName &" (FileName, LinkText, FolderCode, UploadDate, UploadTime, Version, Notes, UserName) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 500, UploadFormRequest("filename")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 300, UploadFormRequest("LinkText")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, 10, MM_IIF(UploadFormRequest("FolderCode"), UploadFormRequest("FolderCode"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(UploadFormRequest("UploadDate"), UploadFormRequest("UploadDate"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 11, UploadFormRequest("UploadTime")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 201, 1, 50, UploadFormRequest("Version")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 201, 1, 1000, UploadFormRequest("Notes")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 201, 1, 50, UploadFormRequest("UserName")) ' adLongVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
By the way, in case its important, the MM_IIF Function (located above the above code) is:
Code:
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
Thanks for any help.
Anthony.
[sub]"Nothing is impossible until proven otherwise"[/sub]