public void SPROC_LoadGroups()
{
//This gets the table name.
string tablename = cboNetChannel.SelectedItem.ToString();
SqlConnection sqlConnectionCmdString = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Rick\Documents\Visual Studio 2010\Projects\Server\database\ClientRegit.mdf;Integrated Security=True;User Instance=True");
//This is the table name and Query that identifies with the selected table
string Command = "SELECT Client_Groups" + "FROM" + tablename;
SqlCommand sqlCommand = new SqlCommand(Command, sqlConnectionCmdString);
SqlDataAdapter objDA = new SqlDataAdapter(sqlCommand);
DataSet dsGroups = new DataSet();
objDA.Fill(dsGroups, "dtGroup");
cboExistingG.DataSource = dsGroups.Tables["dtGroup"];
cboExistingG.DisplayMember = "Client_Groups";
//cboExistingG.ValueMember = "ID";
}
我得到的错误是这个{“'-'附近的语法不正确。”}
我遇到的情况是可以查询名称类似于 GUID 值的表我的表名是 43d5377-0dcd-40e6-b95c-8ee980b1e248
我正在生成使用名为 43d5377-0dcd-40e6-b95c-8ee980b1e248 的网络数据表标识的组。表名是允许的,SQL 不禁止此类表名。
这是我收到错误的代码,我通过创建一个允许我使用所选表值识别查询的查询来进行表映射。