I have tried debugging of code and commenting, but I can't seem to find the problem. I am getting the this error:
Incorrect syntax near 'FROM'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'FROM'.
My code:
public List<string> GetTableColumns(string tableName)
{
List<string> colCollection = new List<string>();
IDataReader reader = null;
using (var cmd = MyDB.GetSqlStringCommand("SELECT * FROM " + tableName))
{
using (reader = MyDB.ExecuteReader(cmd))
{
foreach (DataRow r in reader.GetSchemaTable().Rows)
{
colCollection.Add(r["ColumnName"].ToString());
}
reader.Close();
}
}
return colCollection;
}