Extremly long Strings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a StringBuilder to create a table in html. This table has so much data that the string builder winds up with a length of 43,124,398. This report takes a long time to render so I created a cache table for it. Unfortunately what worked well (slowly, but well) in a aspx page doesn't want to cache to my db. The problem is that when I add the stringbuilder to the sql to insert like so
Dim myParameter As SqlClient.SqlParamete
myParameter = New SqlParameter("@Cache", SqlDbType.Text
myParameter.Value = cache 'This is the StringBuilde
oCom.Parameters.Add(myParameter
myParameter = Nothin
I get an error "System.InvalidCastException: The SqlParameterCollection only accepts non-null SqlParameter type objects, not StringBuilder objects
So if I try
?cache.ToStrin
In the command window I get
"Unable to evaluate expression
If I use it like so
Dim myParameter As SqlClient.SqlParamete
myParameter = New SqlParameter("@Cache", SqlDbType.Text
myParameter.Value = cache.ToString 'This is the StringBuilde
oCom.Parameters.Add(myParameter
myParameter = Nothin
I get an empty value in my db

Anyone have any ideas how to handle extremly long strings? I appreciate any help
Thanks
-- Anthony
 
Anthony said:
I am using a StringBuilder to create a table in html. This table has so much
data that the string builder winds up with a length of 43,124,398. This report
takes a long time to render so I created a cache table for it. Unfortunately
what worked well (slowly, but well) in a aspx page doesn't want to cache to my
db. The problem is that when I add the stringbuilder to the sql to insert like
so:
Dim myParameter As SqlClient.SqlParameter
myParameter = New SqlParameter("@Cache", SqlDbType.Text)
myParameter.Value = cache 'This is the StringBuilder
oCom.Parameters.Add(myParameter)
myParameter = Nothing
I get an error "System.InvalidCastException: The SqlParameterCollection only
accepts non-null SqlParameter type objects, not StringBuilder objects"
So if I try:
?cache.ToString
In the command window I get:
"Unable to evaluate expression"
If I use it like so:
Dim myParameter As SqlClient.SqlParameter
myParameter = New SqlParameter("@Cache", SqlDbType.Text)
myParameter.Value = cache.ToString 'This is the StringBuilder
oCom.Parameters.Add(myParameter)
myParameter = Nothing
I get an empty value in my db.

Anyone have any ideas how to handle extremly long strings? I appreciate any help.
Thanks,
-- Anthony

Convert to binary :P

Mythran
 
SQL Server string parameters are limited to 8K

In order to get that string to the DB you will have to do it without using a SP.
 
Back
Top