I am getting this error
Incorrect syntax near "="
I am getting this error on the line
sda.Fill(dt);
I can't figure out what mistake I have made. I went through many articles but none of them can help me with my problem.
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\TECHNOGEEKZ\Desktop\USSv0.1\USSv0.1\USSv0.1\db\Database.mdf;Integrated Security=True");
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("SELECT name FROM attachments WHERE idno = " + comboBox1.Text + "", con);
DataTable dt = new DataTable();
sda.Fill(dt);
comboBox2.DataSource = dt;
comboBox2.DisplayMember = "name";
comboBox2.ValueMember = "name";
Database table looks like
CREATE TABLE [dbo].[attachments]
(
[Id] INT IDENTITY (1, 1) NOT NULL,
[idno] INT NULL,
[name] VARCHAR (MAX) NULL,
[location] VARCHAR (MAX) NULL
);
Can somebody solve this error? Where exactly is the error in this code?