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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Help: Invalid Parameter Used error

Help: Invalid Parameter Used error

Scheduled Pinned Locked Moved C#
helpdatabasecomgraphicssysadmin
7 Posts 2 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.
  • N Offline
    N Offline
    nudma
    wrote on last edited by
    #1

    Dear All!!! Please help me to resolve this error from the code i m posting here...my image is stored in ms-access database as OLE object under the field name img_stream. I get "Invalid parameter used" error at "bmp = new Bitmap(ms)" private void Page_Load(object sender, System.EventArgs e) { myAccessConnection = new OleDbConnection(connStr); openAccessConnection(); OleDbCommand myCommand = new OleDbCommand("select img_stream from tblImg where img_id=4", myAccessConnection); OleDbDataReader reader = myCommand.ExecuteReader(); if(reader.Read()) { MemoryStream ms = new MemoryStream(); Response.ContentType = "image/jpeg"; byte[] imageContent = (byte[])(reader["img_stream"]); ms.Write(imageContent, 0, imageContent.Length); Bitmap bmp; bmp = new Bitmap(ms); bmp.Save(Response.OutputStream, ImageFormat.Jpeg); ms.Close(); closeAccessConnection(); } else { closeAccessConnection(); } } String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("App_Data/db1.mdb"); OleDbConnection myAccessConnection; protected void openAccessConnection() { if (myAccessConnection.State == ConnectionState.Closed) { myAccessConnection.Open(); } } protected void closeAccessConnection() { if (myAccessConnection.State == ConnectionState.Open) { myAccessConnection.Close(); } } Please help me out..This error is annoying me since last week and no solution yet!! Thankyou!!!

    R 1 Reply Last reply
    0
    • N nudma

      Dear All!!! Please help me to resolve this error from the code i m posting here...my image is stored in ms-access database as OLE object under the field name img_stream. I get "Invalid parameter used" error at "bmp = new Bitmap(ms)" private void Page_Load(object sender, System.EventArgs e) { myAccessConnection = new OleDbConnection(connStr); openAccessConnection(); OleDbCommand myCommand = new OleDbCommand("select img_stream from tblImg where img_id=4", myAccessConnection); OleDbDataReader reader = myCommand.ExecuteReader(); if(reader.Read()) { MemoryStream ms = new MemoryStream(); Response.ContentType = "image/jpeg"; byte[] imageContent = (byte[])(reader["img_stream"]); ms.Write(imageContent, 0, imageContent.Length); Bitmap bmp; bmp = new Bitmap(ms); bmp.Save(Response.OutputStream, ImageFormat.Jpeg); ms.Close(); closeAccessConnection(); } else { closeAccessConnection(); } } String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("App_Data/db1.mdb"); OleDbConnection myAccessConnection; protected void openAccessConnection() { if (myAccessConnection.State == ConnectionState.Closed) { myAccessConnection.Open(); } } protected void closeAccessConnection() { if (myAccessConnection.State == ConnectionState.Open) { myAccessConnection.Close(); } } Please help me out..This error is annoying me since last week and no solution yet!! Thankyou!!!

      R Offline
      R Offline
      Rashmi_Karnam
      wrote on last edited by
      #2

      Try this { byte[] imageContent = (byte[])(reader["img_stream"]); MemoryStream ms = new MemoryStream(imageContent ); Bitmap bmp; bmp = new Bitmap(ms); bmp.Save(ms, ImageFormat.Jpeg); closeAccessConnection(); }

      Rashmi.M.K

      N 1 Reply Last reply
      0
      • R Rashmi_Karnam

        Try this { byte[] imageContent = (byte[])(reader["img_stream"]); MemoryStream ms = new MemoryStream(imageContent ); Bitmap bmp; bmp = new Bitmap(ms); bmp.Save(ms, ImageFormat.Jpeg); closeAccessConnection(); }

        Rashmi.M.K

        N Offline
        N Offline
        nudma
        wrote on last edited by
        #3

        Dear Sender!!!My error is still there..I have tried your instruction but no way out!!Please help...

        R 1 Reply Last reply
        0
        • N nudma

          Dear Sender!!!My error is still there..I have tried your instruction but no way out!!Please help...

          R Offline
          R Offline
          Rashmi_Karnam
          wrote on last edited by
          #4

          Try this.. its working fine here.. i have executed your code its working. { byte[] imageContent = (byte[])(reader["img_stream"]); MemoryStream ms = new MemoryStream(imageContent ); Image bmp = new Bitmap(ms); bmp.Save(ms, ImageFormat.Jpeg); closeAccessConnection(); }

          Rashmi.M.K

          N 1 Reply Last reply
          0
          • R Rashmi_Karnam

            Try this.. its working fine here.. i have executed your code its working. { byte[] imageContent = (byte[])(reader["img_stream"]); MemoryStream ms = new MemoryStream(imageContent ); Image bmp = new Bitmap(ms); bmp.Save(ms, ImageFormat.Jpeg); closeAccessConnection(); }

            Rashmi.M.K

            N Offline
            N Offline
            nudma
            wrote on last edited by
            #5

            I have tried your instruction but now i m getting following errors: 1. 'Image' is an ambiguous reference 2. The type or namespace name 'bmp' could not be found (are you missing a using directive or an assembly reference?) I m using following namespaces: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Drawing.Imaging; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; and i've used no image control...Please help!!!

            R 1 Reply Last reply
            0
            • N nudma

              I have tried your instruction but now i m getting following errors: 1. 'Image' is an ambiguous reference 2. The type or namespace name 'bmp' could not be found (are you missing a using directive or an assembly reference?) I m using following namespaces: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Drawing.Imaging; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; and i've used no image control...Please help!!!

              R Offline
              R Offline
              Rashmi_Karnam
              wrote on last edited by
              #6

              u are reading image from Database. After this where do you want to display? what exactly you want to do?

              Rashmi.M.K

              N 1 Reply Last reply
              0
              • R Rashmi_Karnam

                u are reading image from Database. After this where do you want to display? what exactly you want to do?

                Rashmi.M.K

                N Offline
                N Offline
                nudma
                wrote on last edited by
                #7

                Yes i m reading image from database and i want to display that on web page.

                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