Click here to Skip to main content
15,888,062 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Display Image in gridview store in database Pin
sashidhar24-Nov-09 21:40
sashidhar24-Nov-09 21:40 
GeneralRe: Display Image in gridview store in database Pin
gautamamit824-Nov-09 22:39
gautamamit824-Nov-09 22:39 
GeneralRe: Display Image in gridview store in database Pin
sashidhar24-Nov-09 22:47
sashidhar24-Nov-09 22:47 
AnswerRe: Display Image in gridview store in database Pin
Nishant Singh24-Nov-09 21:43
Nishant Singh24-Nov-09 21:43 
GeneralRe: Display Image in gridview store in database Pin
gautamamit824-Nov-09 23:52
gautamamit824-Nov-09 23:52 
GeneralRe: Display Image in gridview store in database Pin
Nishant Singh25-Nov-09 0:54
Nishant Singh25-Nov-09 0:54 
GeneralRe: Display Image in gridview store in database Pin
sashidhar25-Nov-09 1:03
sashidhar25-Nov-09 1:03 
AnswerRe: Display Image in gridview store in database Pin
carlecomm26-Nov-09 14:32
carlecomm26-Nov-09 14:32 
//upload image
public void OnUpload(Object sender, EventArgs e)
{
int len = Upload.PostedFile.ContentLength;
byte[] pic = new byte[len];
Upload.PostedFile.InputStream.Read (pic, 0, len);

SqlConnection connection = new
SqlConnection (@"server=INDIA INDIA;database=iSense;uid=sa;pwd=india");
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into Image "
+ "(Picture, Comment) values (@pic, @text)", connection);
cmd.Parameters.Add ("@pic", pic);
cmd.Parameters.Add ("@text", Comment.Text);
cmd.ExecuteNonQuery ();
}
finally
{
connection.Close ();
}
}




//load image

private void Page_Load(object sender, System.EventArgs e)
{
MemoryStream stream = new MemoryStream ();
SqlConnection connection = new
SqlConnection (@"server=INDIA INDIA;database=iSense;uid=sa;pwd=india");
try
{
connection.Open ();
SqlCommand command = new
SqlCommand ("select Picture from Image where id"], connection);
byte[] image = (byte[]) command.ExecuteScalar ();
stream.Write (image, 0, image.Length);
Bitmap bitmap = new Bitmap (stream);
Response.ContentType = "image/gif";
bitmap.Save (Response.OutputStream, ImageFormat.Gif);
}
catch
{
string strblandImagePath = Server.MapPath("");
strblandImagePath += "NoImg.gif";
FileStream FileBlandImagestream = File.OpenRead(strblandImagePath);
Bitmap bitImage = new Bitmap(FileBlandImagestream);
Response.ContentType = "image/gif";
bitImage.Save(Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close ();
stream.Close ();
}
}

modified 27-May-14 5:11am.

QuestionQuery String Pin
Amit Patel198524-Nov-09 21:24
Amit Patel198524-Nov-09 21:24 
AnswerRe: Query String Pin
bhavnvyas24-Nov-09 21:29
bhavnvyas24-Nov-09 21:29 
GeneralRe: Query String Pin
dan!sh 24-Nov-09 22:21
professional dan!sh 24-Nov-09 22:21 
GeneralRe: Query String Pin
bhavnvyas24-Nov-09 22:34
bhavnvyas24-Nov-09 22:34 
GeneralRe: Query String Pin
dan!sh 24-Nov-09 22:50
professional dan!sh 24-Nov-09 22:50 
GeneralRe: Query String Pin
bhavnvyas24-Nov-09 23:15
bhavnvyas24-Nov-09 23:15 
AnswerRe: Query String Pin
Nishant Singh24-Nov-09 21:37
Nishant Singh24-Nov-09 21:37 
AnswerRe: Query String Pin
Abhishek Sur24-Nov-09 21:48
professionalAbhishek Sur24-Nov-09 21:48 
AnswerSession Variable Pin
David Mujica25-Nov-09 3:23
David Mujica25-Nov-09 3:23 
AnswerRe: Query String Pin
carlecomm26-Nov-09 14:56
carlecomm26-Nov-09 14:56 
Questionfileupload control Pin
mylogics24-Nov-09 21:06
professionalmylogics24-Nov-09 21:06 
AnswerRe: fileupload control Pin
Blikkies24-Nov-09 21:21
professionalBlikkies24-Nov-09 21:21 
AnswerRe: fileupload control Pin
bhavnvyas24-Nov-09 21:22
bhavnvyas24-Nov-09 21:22 
GeneralRe: fileupload control Pin
mylogics24-Nov-09 21:24
professionalmylogics24-Nov-09 21:24 
QuestionScreen resolution Pin
shankbond24-Nov-09 20:53
shankbond24-Nov-09 20:53 
AnswerRe: Screen resolution Pin
bhavnvyas24-Nov-09 21:24
bhavnvyas24-Nov-09 21:24 
Questiontreeview Pin
aruna120124-Nov-09 20:29
aruna120124-Nov-09 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.