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";
}
私が得ているエラーはこれです {"Incorrect syntax near '-'."}
テーブル名が 43d5377-0dcd-40e6-b95c-8ee980b1e248 の GUID 値に似た名前のテーブルとしてクエリを実行できる状況が発生しました
43d5377-0dcd-40e6-b95c-8ee980b1e248 という名前のネットワーク データ テーブルで識別されるグループを生成しています。テーブル名は許可されており、SQL はそのようなテーブル名を禁止していません。
これは私のコードです。エラーが発生しています。選択したテーブル値でクエリを識別できるようにするクエリを作成して、これをテーブル マッピングしています。