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. C# mysql problem

C# mysql problem

Scheduled Pinned Locked Moved C#
csharpdatabasemysqlhelp
1 Posts 1 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.
  • B Offline
    B Offline
    babamara
    wrote on last edited by
    #1

    hi all i want to save images to database. I use this code private int SaveToDB(string imgName, byte[] imgbin, string imgcontenttype) { //use the web.config to store the connection string MySqlConnection connection = new MySqlConnection(ConfigurationSettings.AppSettings["DSN"]); MySqlCommand command = new MySqlCommand( "INSERT INTO Image (img_name,img_data,img_contenttype) VALUES ( @img_name, @img_data,@img_contenttype )", connection ); MySqlParameter param0 = new MySqlParameter( "@img_name", MySqlDbType.VarChar,50 ); param0.Value = imgName; command.Parameters.Add( param0 ); MySqlParameter param1 = new MySqlParameter( "@img_data", MySqlDbType.LongBlob ); param1.Value = imgbin; command.Parameters.Add( param1 ); MySqlParameter param2 = new MySqlParameter( "@img_contenttype", MySqlDbType.VarChar,50 ); param2.Value = imgcontenttype; command.Parameters.Add( param2 ); connection.Open(); int numRowsAffected = command.ExecuteNonQuery(); connection.Close(); return numRowsAffected; } I have no errors it tells me that the image is save but when i go to my database there is only new row with no data. Where i am wrong P.S. I use MySql connector -- modified at 13:09 Friday 17th March, 2006

    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