Carlos Sanchez

Carlos Sanchez

  • NA
  • 264
  • 0

Uploading a Image File to a DataBase

Jul 19 2004 3:33 PM
Somebody know how to upload a Image File to a DataBase. The file is selceted by the user by a OpenFileDialog. if (OpenFileDialog1.Show()==DialogResult.Ok) { Image img = Image.FromFile(OpenFileDialog1.FileName) //Uploading img to the DataBase } I have the next wrong code to Upload img to the DataBase: SqlCommand InsertCommand = new SqlCommand("INSERT TO MyTable (ImageColumn) VALUES (@Image)",MyConnacetion); InsertCommand.Parameters.Add("@Image",img); //This line throws an error MyConnection.Open(); InsertCommand.ExecutQuery(); MyConnection.Close(); When I add the paremeter, the next exception is thrown: "Index (zero based) must be greater than or equal to zero and less than the size of the argument list." Any Idea? Thanx in advance.

Answers (3)