Click to See Complete Forum and Search --> : VarChar and updating a DB problem


silencer01
08-13-2004, 10:36 AM
Hi All,

I'm new to ASP and i'm trying to debug a pre-existing project which uses stored procedures to update a SQL2000 Database. The problem being that they have used VarChar with 4000 characters (which is the maximium). I need to be able to store more the 4000 characters to i have changed the Database to NText. This is causing an error when i attempt to add more the 4000 characters. In creating the parameters the application uses a varible name AdVarWchar. I guess i need to change this to accept NText values so it there and NText equivalent to AdVarChar?

Here is the code:

Sub Savetext
Dim conn, cmd

Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("ManageConn")
Set cmd = Server.CreateObject("ADODB.Command")

cmd.CommandType = adCmdStoredProc
cmd.ActiveConnection = conn
cmd.CommandText = "spUpdSponsoring"

cmd.Parameters.Append cmd.CreateParameter("Text", adVarWChar, adParamInput, 4000, Text)
cmd.Parameters.Append cmd.CreateParameter("EventsText", adVarWChar, adParamInput, 4000, EventsText)
cmd.Execute

Set cmd = Nothing
Conn.Close
Set Conn = Nothing
End Sub

Any help or suggestions appreciated.

CardboardHammer
08-13-2004, 11:29 AM
Change the table and input parameters to allow up to 8000 bytes for the field. varchar uses 1 byte per character. nvarchar uses 2 bytes per character. They both have the same byte limit, so the character limit for varchar is 8000 and the character limit for nvarchar is 4000; those numbers represent the maximum values for "length" for each type. To store larger amounts of data in a field, you can use text/ntext as the type, but note that there are significant differences in how the data is stored and how you interact with it. Check your documentation for the details.