• 949
  • 1.2k
  • 142.4k

Same message error coming always back

Apr 26 2019 1:02 PM
This code are well wroted. But when I press to the "button1" where the process is to save in my database. But there is always this error message: Incorrect syntax near the keyword 'Table'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.Diagnostics;
namespace search
public partial class Form1 : Form
public Form1()
SqlConnection conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Users\\PC\\Documents\\GlobalCsharp\\Save_Image_text_DB\\search\\App_Datas\\Database1.mdf;Integrated Security = True");
//SqlCommand comm;
string imgLocation = "";
SqlCommand cmd;
private void button3_Click(object sender, EventArgs e)
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "png files (*.png)|*.png |jpg files(*.jpg)All fils(*.*)|*.*";
if (dialog.ShowDialog() == DialogResult.OK)
imgLocation = dialog.FileName.ToString();
pictureBox1.ImageLocation = imgLocation;
private void button1_Click(object sender, EventArgs e)
byte[] images = null;
FileStream Stream = new FileStream(imgLocation, FileMode.Open, FileAccess.Read);
BinaryReader brs = new BinaryReader(Stream);
images = brs.ReadBytes((int)Stream.Length);
string sqlQuery = "Insert into Table(ID,Name,Image)Values('" + textID.Text + "','" + textName.Text + "',@images)"; // The error come on this line
cmd = new SqlCommand(sqlQuery, conn);
cmd.Parameters.Add(new SqlParameter("@images", images));
int N = cmd.ExecuteNonQuery();
MessageBox.Show(N.ToString() + "Datas Saved Sucessfully");

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (5)