ASP Code to update field using SP (text field)

Aleks used Ask the Experts™
We had a field which was nvarchar 8000, it was changed to a text field to accomodate more characters.

I currently have the code below to call the Stored Procedure, but the parameter is for 8000 characters, how should I change it to allow the entry of as many characters as the text field allows?


Set UpdateSignature = Server.CreateObject ("ADODB.Command")
UpdateSignature.ActiveConnection = MM_bluedot_STRING
UpdateSignature.CommandText = "UPDATE Userlogin SET Emailsignature = ? WHERE  userid = ?"
UpdateSignature.Parameters.Append UpdateSignature.CreateParameter("MMColParam", 200, 1, 8000, MM_IIF(Request.Form("signature"), Request.Form("signature"), UpdateSignature__MMColParam & ""))
UpdateSignature.Parameters.Append UpdateSignature.CreateParameter("MMColParam2", 3, 1, 4, MM_IIF(Session("Userid"), Session("Userid"), UpdateSignature__MMColParam2 & ""))
UpdateSignature.CommandType = 1
UpdateSignature.CommandTimeout = 0
UpdateSignature.Prepared = true


Open in new window

Something else that may be relevant is that this field is intended to save the user's signature block, if they add an image (their logo) then the HTML editor converts it into characters and this is where 8000 characters don't seem to be enough.
I am not sure if because we are including an image I may need to use a different type of data for the user, otherwise I guess text fiedl will work.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Web Ninja at large
i would advise using the infamous file, which includes all constants definitions for all things ADO. simply download it and include it on your page, and use the constant name when setting your parameters. in this case, it would be adLongVarChar, which is set to 201

if you just want to use the numerical value, your code would look like:

UpdateSignature.Parameters.Append UpdateSignature.CreateParameter("MMColParam", 201, 1, Len( "" & Request.Form("signature") ), MM_IIF(Request.Form("signature"), Request.Form("signature"), UpdateSignature__MMColParam & ""))

I bolded the changes you'll need to make. since TEXT fields have a very large size, it's easier just to specify the length of your data, as shown with the LEN function


Ill have to learn more later about the include file.
I changed the code and seems to work, is text field OK ?
Big MontyWeb Ninja at large

yes, text fields are the "next step up" from varchars. Unless you're storing binary data, text fields are fine


It seems to have worked!  thanks. all set here.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial