if (openFileDialog.ShowDialog() == DialogResult.OK) {label1.Text = openFileDialog.FileName;} string[] FullFileName = openFileDialog.FileName.Split('\\'); string fname = FullFileName.Last().ToString(); byte[] FileContent; FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open); BinaryReader bs = new BinaryReader(fs); FileContent = bs.ReadBytes(Convert.ToInt32(fs.Length)); fs.Close(); bs.Close(); string Query = "insert into D (FileName,[File]) values(@name,@data)"; MySqlCommand cmd = new MySqlCommand(Query, con); con.Open(); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@name", fname); cmd.Parameters.AddWithValue("@data", FileContent); cmd.ExecuteNonQuery(); MessageBox.Show("data saved");
MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[File]) values('Receipt.pdf',_binary '%PDF-1.3 %âãÃÃ
INSERT INTO D (FileName, `File`) Values (...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)