title: Save Image in MySQL via C# application
body: <p>I have a client application in C#, which is meant to take in the location of an image <code>(DataType: VarChar)</code>. This application is then supposed to invoke a web service, which in turn will store the Image (NOT the location) in a local MySQL Database.</p>
  
  <p>The problem is, I realized that i am able to pass all the other data from the form to the database EXCEPT for the image...Can anyone please point out what I am doing wrong here? Any help will be greatly appreciated.</p>
  
  <p>ps - I know that a lot of you will be suggesting me to save the images in a file system rather than on the database itself....but the thing is, my database is not that big anyways so saving the images on the database itself will not be that big of a deal hopefully :)</p>
  
  <p>Here is my table in MySQL,</p>
  
  <pre><code>create table testImage(
  id int not null auto_increment,
  name varchar(50),
  age int,
  image blob,
  primary key(id));
  </code></pre>
  
  <p>And here is the <code>WebMethod</code> which is meant to insert the data into the table...it works when the <code>image</code> field is commented out.</p>
  
  <pre><code>[WebMethod]
          public string sendDataToMySql(string get_name, int get_age, byte[] buffer)
          {
              string MyConString = "SERVER=localhost;" +
                    "DATABASE=test;" +
                    "UID=root;" +
                    "PASSWORD=password;";
  
              string name_new = get_name;
              int age_new = get_age;
              byte[] buffer_new = buffer;
  
  
              MySqlConnection connection = new MySqlConnection(MyConString);
              connection.Open();
              MySqlCommand command = new MySqlCommand("", connection);
              command.CommandText = "insert into testdata(name, age, image) values(@name, @age, @image);";
  
              command.Parameters.AddWithValue("@name", name_new);
              command.Parameters.AddWithValue("@age", age_new);
              command.Parameters.AddWithValue("@image", buffer_new);
  
              command.ExecuteNonQuery();
  
              connection.Close();
  
              return "Task Performed!";
  
          }
  </code></pre>