Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. out of memory exception

out of memory exception

Scheduled Pinned Locked Moved C#
databasesysadminperformancehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eswar pothula
    wrote on last edited by
    #1

    hi every body, in my application i want to retrieve image from database and it will show on picture box, so my code is try { int no = int.Parse(textBox2.Text); SqlConnection con = new SqlConnection("user id=sa;password=sa123;server=192.168.0.44;database=eswar"); SqlCommand cmd = new SqlCommand("select imagedata from image1 where sno=" + no, con); //byte[] barrImg=(byte[])cmdSelect.ExecuteScalar(); cmd.Parameters.Add(textBox2.Text, SqlDbType.Int, 4); cmd.Parameters[textBox2.Text].Value = this.textBox2.Text; con.Open(); byte[] imgarr = (byte[])cmd.ExecuteScalar(); string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write); fs.Write(imgarr, 0, imgarr.Length); fs.Flush(); fs.Close(); pictureBox1.SizeMode = PictureBoxSizeMode.Normal; pictureBox1.Image = Image.FromFile(strfn); cmd.Dispose(); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } when my application is running it will shows a out of memory exception pls help me thanks in advance.........

    S L 2 Replies Last reply
    0
    • E eswar pothula

      hi every body, in my application i want to retrieve image from database and it will show on picture box, so my code is try { int no = int.Parse(textBox2.Text); SqlConnection con = new SqlConnection("user id=sa;password=sa123;server=192.168.0.44;database=eswar"); SqlCommand cmd = new SqlCommand("select imagedata from image1 where sno=" + no, con); //byte[] barrImg=(byte[])cmdSelect.ExecuteScalar(); cmd.Parameters.Add(textBox2.Text, SqlDbType.Int, 4); cmd.Parameters[textBox2.Text].Value = this.textBox2.Text; con.Open(); byte[] imgarr = (byte[])cmd.ExecuteScalar(); string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write); fs.Write(imgarr, 0, imgarr.Length); fs.Flush(); fs.Close(); pictureBox1.SizeMode = PictureBoxSizeMode.Normal; pictureBox1.Image = Image.FromFile(strfn); cmd.Dispose(); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } when my application is running it will shows a out of memory exception pls help me thanks in advance.........

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      First, comment out your try catch block, and then look at where it does happen. Second: Put your code into <pre></pre> blocks

      1 Reply Last reply
      0
      • E eswar pothula

        hi every body, in my application i want to retrieve image from database and it will show on picture box, so my code is try { int no = int.Parse(textBox2.Text); SqlConnection con = new SqlConnection("user id=sa;password=sa123;server=192.168.0.44;database=eswar"); SqlCommand cmd = new SqlCommand("select imagedata from image1 where sno=" + no, con); //byte[] barrImg=(byte[])cmdSelect.ExecuteScalar(); cmd.Parameters.Add(textBox2.Text, SqlDbType.Int, 4); cmd.Parameters[textBox2.Text].Value = this.textBox2.Text; con.Open(); byte[] imgarr = (byte[])cmd.ExecuteScalar(); string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write); fs.Write(imgarr, 0, imgarr.Length); fs.Flush(); fs.Close(); pictureBox1.SizeMode = PictureBoxSizeMode.Normal; pictureBox1.Image = Image.FromFile(strfn); cmd.Dispose(); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } when my application is running it will shows a out of memory exception pls help me thanks in advance.........

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        see my sig. and use Exception.ToString() not Exception.Message :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups