语法错误System.Data.SqlClient.SqlException:','附近的语法不正确。

时间:2019-05-20 18:49:07

标签: c# sql datagridview

我一直在试图准确地找出语法错误的出处,并且我一直在寻找过去的答案,却找不到与我有关的错误。

string conStr = "Data Source=CPS1113020004; Initial Catalog=Coweta Public 
Schools; Integrated Security=True";
            var select = "SELECT Student_Number " +
                "FROM dbo.[12 Grade Chromebooks] " +
                "WHERE Student_Number = " + studentIDtxtBox ;
            var c = new SqlConnection(conStr); 
            var dataAdapter = new SqlDataAdapter(select, c);

            var commandBuilder = new SqlCommandBuilder(dataAdapter);
            var ds = new DataSet();
            dataAdapter.Fill(ds);
            dataGridView1.ReadOnly = true;
            dataGridView1.DataSource = ds.Tables[0];

0 个答案:

没有答案