TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
amit
NA
10
4k
how i retrieve pdf files in gridview using mssql 2008
Dec 31 2014 1:29 AM
how i retrieve pdf files in gridview using mssql 2008 and in Database i use varchar(max) instead of varbinary(max) in sql 2008 server ; it gives error "how to convert system.string to system.byte[] " .... PLZ HELP
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Net;
public partial class Defaultpdf : System.Web.UI.Page
{
SqlConnection sqlcon = new SqlConnection("Data Source=;Initial Catalog=;User ID=;Password=");
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
string qstr;
byte[] b = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
qstr = Request.QueryString["ReqDocId"];
SqlCommand sqlcmd = new SqlCommand("Select ReqDoc from tbl_name where ReqDocId='" + qstr + "'", sqlcon);
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
b =((byte[])dt.Rows[0][0]);
Response.ContentType = "application/pdf";
Response.BinaryWrite(b);
}
}
}
}
Reply
Answers (
0
)
I want to create web portal like IP Messenger in MVC
Unabletocastobjectoftype 'System.String' totype 'System.byte