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
charan sekhar
NA
108
0
reteriving images from database
May 1 2010 5:05 AM
hi iam using asp.net with c#
iam saving two images in database but while retreving only one image is displaying can you correct my code
saving code
========
protected
void
Button1_Click(
object
sender,
EventArgs
e)
{
if
(FileUpload1.HasFile && FileUpload2.HasFile)
{
img1.ImageUrl = imgc.ImageUrl;
img2.ImageUrl = imgo.ImageUrl;
FileUpload1.SaveAs(MapPath(
"~/images/"
+ FileUpload1.FileName));
imgc.ImageUrl =
"~/images/"
+ FileUpload1.FileName;
FileUpload2.SaveAs(MapPath(
"~/images/"
+ FileUpload2.FileName));
imgo.ImageUrl =
"~/images/"
+ FileUpload2.FileName;
con.Open();
SqlCommand
cmd =
new
SqlCommand
(
"Addimgproc"
, con);
cmd.CommandType =
CommandType
.StoredProcedure;
cmd.Parameters.AddWithValue(
"@Shop"
,
"Alsafa"
);
FileInfo
imageinfo =
new
FileInfo
(FileUpload1.PostedFile.FileName.Trim());
byte
[] content =
new
byte
[imageinfo.Length];
FileStream
imagestream = imageinfo.OpenRead();
imagestream.Read(content, 0, content.Length);
imagestream.Close();
//2nd upload
FileInfo
imageinfo1 =
new
FileInfo
(FileUpload2.PostedFile.FileName.Trim());
byte
[] content1 =
new
byte
[imageinfo1.Length];
FileStream
imagestream1 = imageinfo1.OpenRead();
imagestream1.Read(content1, 0, content1.Length);
imagestream1.Close();
cmd.Parameters.AddWithValue(
"@imgc"
, content);
cmd.Parameters.AddWithValue(
"@imgo"
, content1);
cmd.ExecuteNonQuery();
con.Close();
}
}
reterieving code
==========
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
SqlCommand
cmd =
new
SqlCommand
(
"select imgc,imgo from images where Shop='Alsafa'"
, con);
con.Open();
SqlDataReader
dr = cmd.ExecuteReader();
if
(dr.HasRows)
{
while
(dr.Read())
{
Response.ContentType =
"image/gif";
Response.BinaryWrite((
byte
[])dr[
"imgc"
]);
Response.BinaryWrite((
byte
[])dr[
"imgo"
]);
}
}
dr.Close();
con.Close();
}
i want to display the two images side by side . can you give example which helps me.
Reply
Answers (
1
)
java script function
Dyanamic Table paging