Click here to Skip to main content
16,008,750 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to store images in sql database, asp.net with c# Pin
yogesh_softworld12320-Oct-07 20:47
yogesh_softworld12320-Oct-07 20:47 
GeneralRe: How to store images in sql database, asp.net with c# Pin
Christian Graus20-Oct-07 21:09
protectorChristian Graus20-Oct-07 21:09 
GeneralRe: How to store images in sql database, asp.net with c# Pin
MoustafaS21-Oct-07 14:32
MoustafaS21-Oct-07 14:32 
AnswerRe: How to store images in sql database, asp.net with c# Pin
meeram39520-Oct-07 20:51
meeram39520-Oct-07 20:51 
GeneralRe: How to store images in sql database, asp.net with c# Pin
Christian Graus20-Oct-07 21:16
protectorChristian Graus20-Oct-07 21:16 
AnswerRe: How to store images in sql database, asp.net with c# Pin
Abhijit Jana21-Oct-07 5:21
professionalAbhijit Jana21-Oct-07 5:21 
GeneralRe: How to store images in sql database, asp.net with c# Pin
Bino B21-Oct-07 20:03
Bino B21-Oct-07 20:03 
AnswerRe: How to store images in sql database, asp.net with c# Pin
Bino B21-Oct-07 20:02
Bino B21-Oct-07 20:02 
its quite easy and not as complicated as u think.

im pasting the whole funny code here...use it as u like

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;

public partial class SQLBinary : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//UploadImage();
}
public void UploadImage()
{
// Creating a bytearray[] from the input image
int ImgLen = FileUpload1.PostedFile.ContentLength;
string strSQL="";
byte[] FileImg = new byte[ImgLen];
FileUpload1.PostedFile.InputStream.Read(FileImg, 0, ImgLen);
// Inserting the image to DB
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connstr"].ToString());
try
{
con.Open();
strSQL = "INSERT INTO TESTIMAGE (EIMAGE) VALUES (@pic)";
SqlCommand cmd = new SqlCommand(strSQL, con);
cmd.Parameters.AddWithValue("@pic", FileImg);
cmd.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
UploadImage();
}
protected void Button1_Click(object sender, EventArgs e)
{
MemoryStream stream = new MemoryStream();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connstr"].ToString());
try
{
con.Open();
SqlCommand command = new SqlCommand("SELECT EIMAGE FROM TESTIMAGE", con);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
Bitmap bitmap = new Bitmap(stream);
//To SERVE
//Response.ContentType = "image/gif";
//bitmap.Save(Response.OutputStream, ImageFormat.Gif);
//TO SAVE
bitmap.Save(Server.MapPath("image")+ "/" + "aa.jpg");
Image1.ImageUrl = Server.MapPath("image")+ "/" + "aa.jpg";
}
finally
{
con.Close();
stream.Close();
}
}
}


Regards
Bino
http://www.codepal.co.nr

Questionpopup window Pin
Sarfaraj Ahmed20-Oct-07 18:29
Sarfaraj Ahmed20-Oct-07 18:29 
GeneralRe: popup window Pin
Guffa20-Oct-07 23:10
Guffa20-Oct-07 23:10 
AnswerRe: popup window Pin
Bino B21-Oct-07 20:07
Bino B21-Oct-07 20:07 
QuestionNeed Help with ASP.NET implementation of FCKeditor Pin
B.A20-Oct-07 12:35
B.A20-Oct-07 12:35 
AnswerRe: Need Help with ASP.NET implementation of FCKeditor Pin
kenexcelon21-Oct-07 14:49
kenexcelon21-Oct-07 14:49 
QuestionFailure in sending mail Pin
ebenezervedakumar20-Oct-07 7:18
ebenezervedakumar20-Oct-07 7:18 
AnswerRe: Failure in sending mail Pin
Christian Graus20-Oct-07 20:40
protectorChristian Graus20-Oct-07 20:40 
QuestionFailure in sending mail Pin
ebenezervedakumar20-Oct-07 7:17
ebenezervedakumar20-Oct-07 7:17 
AnswerRe: Failure in sending mail Pin
Paul Conrad27-Oct-07 12:02
professionalPaul Conrad27-Oct-07 12:02 
QuestionT-Shirt design application in asp.net 2.0 Pin
Mujibur Rahman20-Oct-07 4:26
Mujibur Rahman20-Oct-07 4:26 
AnswerRe: T-Shirt design application in asp.net 2.0 Pin
Christian Graus20-Oct-07 20:42
protectorChristian Graus20-Oct-07 20:42 
GeneralT-Shirt application like click-shirt.com Pin
Mujibur Rahman20-Oct-07 20:59
Mujibur Rahman20-Oct-07 20:59 
GeneralRe: T-Shirt application like click-shirt.com Pin
Christian Graus20-Oct-07 21:13
protectorChristian Graus20-Oct-07 21:13 
QuestionHow to update tow table in single query Pin
rahul.net1120-Oct-07 2:26
rahul.net1120-Oct-07 2:26 
AnswerRe: How to update tow table in single query Pin
szukuro20-Oct-07 3:40
szukuro20-Oct-07 3:40 
GeneralRe: How to update tow table in single query Pin
rahul.net1120-Oct-07 3:59
rahul.net1120-Oct-07 3:59 
QuestionSignOut code does not work properly.......... Pin
ajau19-Oct-07 23:15
ajau19-Oct-07 23:15 

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.