Click here to Skip to main content
15,922,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,.
i want to get data base i want to display data into rich text box control from below snipet can u guide or send snippets

C#
<%@ webhandler language="C#" class="NWEmpPhotoHandler" %>

using
System;

using
System.Web;

using
System.Data;

using
System.Data.SqlClient;

public
class NWEmpPhotoHandler : IHttpHandler

{

public bool IsReusable { get { return true; } }

public void ProcessRequest(HttpContext ctx)

{

string id = ctx.Request.QueryString["id"];

SqlConnection con = new SqlConnection("Data Source=server;Initial Catalog=schema;Persist Security Info=True;User ID=userid;Password=password");

SqlCommand cmd = new SqlCommand("SELECT filedata FROM mytable WHERE DocID = @DocID", con);

cmd.CommandType =
CommandType.Text;

cmd.Parameters.Add(
"@DocID", id);

con.Open();

byte[] doct = (byte[])cmd.ExecuteScalar();

con.Close();

ctx.Response.ContentType =
"application/pdf";

// ctx.Response.OutputStream.Write(doct, 78, doct.Length - 78);

ctx.Response.BinaryWrite(doct);

}

}
Posted
Updated 13-Feb-12 18:01pm
v5
Comments
Sergey Alexandrovich Kryukov 14-Feb-12 2:12am    
What RichTextBox control is ASP.NET? How it is related to PDF I can see in your code?
--SA

Don't put it into the Response. Put it into your RichTextBox Control.
 
Share this answer
 
convert binary in string and than put this string in rich textbox. and write "application/msword"; in place of "application/pdf";

or see This[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900