I have a C# program that creates Access MDB files. The names of the tables and columns are fixed, and I have no chance to change them. And unfortunately, one of the columns is named “Group”.
The code that I have written looks like:
string indexSQL = buildIndexString(table.TableName);
//indexSQL = "CREATE INDEX comp ON ExpFactMap([Group]);"
new OleDbCommand(indexSQL, conn).ExecuteNonQuery();
When ExecuteNonQuery() is executed, I get a syntax error. The code works correctly if I use any column other than “Group”. The problem seems to be that it is interpreting Group as a keyword rather than as a column name.
Does anyone know how to get around this problem? In an ideal world, I would change the name of the column, but unfortunately that is not a possibility.
Group is not the only reserved word you’re attempting to use as an object name in your DDL statement:
Unfortunately, “comp” is also a reserved word. See Problem names and reserved words in Access.
Bracket that reserved word in your
CREATE INDEXstatement: