September 11th, 2008, 01:13 PM
C# error "Cannot apply indexing with  to an expression of type 'method group'
The database sometime doesn't contain a field/column name, so I used the if-statement to check for that. I didn't have this problem with VB.NET but in C#, I get a compiler error.
The compiler error said "Cannot apply indexing with  to an expression of type 'method group'".
The blue underline pointed to oDataSet in the if-statement. I'm not sure exactly what the problem is other than I need to add the "()" or "" character to object.
if (oDataSet.Tables.Columns.Contains["BodyStyle"] == true)
this.txtBody.Text = oDataSet.Tables.Rows["BodyStyle"].ToString();
Edited: It's been a day already and I guess no one know the solution to the problem so I'm leaving this posting open. For now, I came up a temporary workaround to the problem..
public bool ftnDataSet_IsColumnExistsQQ(System.Data.DataTable oDataTable, string sColumnName, ref bool bColumnExistQQ)
string sErrorMsg = "";
//oDataTable = ...
//sColumnName = ...
bColumnExistQQ = false;
foreach (System.Data.DataColumn oDataColumn in oDataTable.Columns)
if (oDataColumn.ColumnName == sColumnName)
bColumnExistQQ = true;
catch (Exception ex)
sErrorMsg = ex.Message.ToString(); //To bypass the compiler's warning message...
//sErrorMsg = System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() + " General Error: Exception - '" + ex.Message.ToString() + "'";
Last edited by fletchsod; September 12th, 2008 at 11:23 AM.