The landlord wants to save the zip file to the mysql database, which is developed in C. However, an error is reported during the insert process. The code is as follows: byte [] bytesnull; bytesFile. readAllBytes (@ & quot; E: MySqlTestMySqlTestMySqlTest.zip & quot;); MySql. data. mySqlClient. mySqlConnectionconnSqlUtil. getConn (); MySql. data. mySqlClient. mySqlCommandcmdn mysql binary file c # Database
The landlord wants to save the zip file to the mysql database, which is developed in C. However, an error is reported during the insert process. The code is as follows:
Byte [] bytes = null;
Bytes = File. ReadAllBytes (@ "E: \ MySqlTest \ MySqlTest.zip ");
MySql. Data. MySqlClient. MySqlConnection conn = SqlUtil. GetConn ();
MySql. Data. MySqlClient. MySqlCommand cmd = new MySql. Data. MySqlClient. MySqlCommand ();
Cmd. CommandText = "insert into model (Model_ID, File) values (@ ID, @ ParaBlob )";
Cmd. Parameters. Add ("@ ID", MySql. Data. MySqlClient. MySqlDbType. Int32 );
Cmd. Parameters. Add ("@ ParaBlob", MySql. Data. MySqlClient. MySqlDbType. LongBlob );
cmd.Parameters[0].Value = 15; cmd.Parameters[1].Value = bytes; cmd.Connection = conn; int affectedrows = cmd.ExecuteNonQuery();
Insert an error as follows:
[Img = Beijing
Is there any problem when inserting my SQL statement? thank you!