0

i can add images without any problem to my website.with my below code..i am using linq and asp.net with c#....

ImageDatabaseDataContext imdb = new ImageDatabaseDataContext();
Dosyalar ds;
Katilimci kt;
protected void btnEkle_Click(object sender, EventArgs e)
{
    if (FileUpload1.FileContent != null)
    {
        string dosyaAdi = Guid.NewGuid().ToString();
        byte[] icerik = FileUpload1.FileBytes;
        string dosyaTipi = FileUpload1.PostedFile.ContentType;

        try
        {
            ds = new Dosyalar();
            kt = new Katilimci();
            kt.AdSoyad = txtAdSoyad.Text;
            kt.BolgeMudurlugu = txtBolgeMudurlugu.Text;
            kt.Gorevi = txtGorev.Text;
            kt.NoktaAd = txtNoktaAd.Text;
            kt.NoktaTuru = txtNoktaTuru.Text;
            imdb.Katilimcis.InsertOnSubmit(kt);
            imdb.SubmitChanges();
            int idsi = kt.KID;

            ds.DosyaAD = dosyaAdi;
            ds.DosyaICERIK = icerik;
            ds.DosyaTIP = dosyaTipi;
            ds.KID = idsi;
            imdb.Dosyalars.InsertOnSubmit(ds);

            imdb.SubmitChanges();

        }
        catch (Exception ex)
        {
            lblHataci.Text = ex.Message;
        }
    }
}

here is my question..How do i show my images that i was saving on sql server?on asp.Net website with linq queries?

Thanks for your answer...

Erdinç
  • 267
  • 2
  • 7
  • 15
  • Please replace the code in your question with a sample that is more narrowly-focused on the exact problem you're having. Among other things, I have no idea which image you're referring to. – John Saunders Dec 08 '09 at 01:44
  • he's probably talking about the posted file that's being saved into the database. – John Boker Dec 08 '09 at 01:46

2 Answers2

1

you can use the solution to this question as long as you get the contents of the image from the database. it doesnt depend on any linq-to-sql.

Dynamically Rendering asp:Image from BLOB entry in ASP.NET

Community
  • 1
  • 1
John Boker
  • 82,559
  • 17
  • 97
  • 130
0

`public class ImageHandler : IHttpHandler {

public void ProcessRequest(HttpContext context)
{
    using(Image image = GetImage(context.Request.QueryString["ID"]))
    {    
        context.Response.ContentType = "image/jpeg";
        image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
    }
}

public bool IsReusable
{
    get
    {
        return true;
    }
}

}`

this code solves my question thank you.

Erdinç
  • 267
  • 2
  • 7
  • 15