How to retrieve html text from stored procedure in C# -


i have multi line text in html format stored in database this:

@"<font  size='1'>  <p><span ...='25' width='120' src='http://www.mysite.com/images/new-site-logo.jpg'/></span></p>  <h2 ...</table></font>" 

and have stored procedure retrieve database.

in c# call stored procedure in myclass.cs this:

public string getehtmlcontent(int id) {     ...     sqlparameter htmlparam = new sqlparameter("@htmlemail","");     htmlparam.direction = parameterdirection.output;     cmd.parameters.add(htmlparam);     cmd.parameters.add(new sqlparameter("@id", id));     cmd.executenonquery();     htmlcontent = httputility.htmlencode(htmlparam.value);     ... } 

it gets id input parameter , should give html output "@" first character in htmlparam.value.

can me how should html context in htmlparam?

thanks in advance,
mona

what parameter list on stored procedure in t-sql like??

allow me guess - have

create procedure dbo.yourhtmlretrievelproc        ...    @htmlemail varchar outupt 

or that.

any varchar that's defined parameter without specifying length defaults 1 character in length - that's why you're getting 1 character....

you need specify length:

@htmlemail varchar(2000) outupt 

or even:

@htmlemail varchar(max) outupt 

for same reason, change c# code from:

sqlparameter htmlparam = new sqlparameter("@htmlemail",""); 

to:

sqlparameter htmlparam = new sqlparameter("@htmlemail", sqldbtype.varchar, 2000); 

you need make sure use same length defined in stored procedure header. use int.maxvalue if you're defined varchar(max) parameter in t-sql


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -