Wednesday, March 7, 2012

How to store large text-strings in a sql-field?

I will store text with more than 8.000 characters in a sql-database. I defined my field as data-type=text. But when I paste a large text string into the database, only some of the text is being saved. The text also changes to "<long text> so I can't change it.

I tried to make some asp-code to handle the problem, but I can't find the right constants to use according to the data-type=text. In my example I use the constant "adBinary".

strInfo = Request.Form("txtInfo")
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
.ActiveConnection = MyConn
.CommandText = "add_Info"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter ("@.Info", adBinary, adParamInput, , strInfo)
.Execute lngRecs, , adExecuteNoRecords
Set cmd = Nothing
End With

Is there anybode that can help me?I think you are using SQL-SERVER,
First check the maximum size allowed in TEXT type of Field.

I doubt if it can allow so many characters.|||I found the solution. In the asp-code, I use datatype "varchar" and number of characters like 2147483647.

No comments:

Post a Comment