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
ds ps
NA
61
0
displaying selected image from database in a new web page
Nov 29 2009 11:44 PM
on click on selected image, new page will display the image stored in the database table,so on page load event i 've following codes.. but there is error with response.binarywrite(.....
can anyone help me to make it right??i tried so many times..but not succeed...plz help
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
int
PictureID = 1;
//Connect to the database and bring back the image contents & MIME type for the specified picture
string
ConStr = System.Configuration.
ConfigurationSettings
.AppSettings.Get(
"SQLCON"
).ToString();
SqlConnection
cn =
new
SqlConnection
(ConStr);
//cn.Open();
// string SQL = "INSERT INTO ContractImages (ContractId, PartyConrNum ,Title, UploadDate, MIMEType, ImageData) VALUES (@Title, @MIMEType, @ImageData)"
string
SQLQRY =
"SELECT [MIMEType], [ImageData] FROM ContractImages WHERE [ImageId] = @PictureID"
;
SqlCommand
cmd =
new
SqlCommand
(SQLQRY, cn);
cmd.Parameters.AddWithValue(
"@PictureID"
, PictureID);
//PictureTitle.Text.Trim());
cn.Open();
SqlDataReader
imagereader = cmd.ExecuteReader(
CommandBehavior
.CloseConnection);
while
(imagereader.Read())
{
Response.ContentType = imagereader[
"MIMEType"
].ToString ();
Response.BinaryWrite(imagereader[
"ImageData"
]);
}
imagereader.Close();
cn.Close();
}
Reply
Answers (
0
)
Date and weeks
register key