Hi forum, I need some help! Ive converted a script from VB to C#. Come across the: 'System.Data.DataSet.Tables' is a 'property' but is used like a 'method' .Here attaching the code.
public
void PopulateMenu()
{
System.Data.
DataSet dst = GetMenuData();
foreach (System.Data.DataRow masterRow in dst.Tables("tblModules").Rows())
// ERROR 'System.Data.DataSet.Tables' is a 'property' but is used like a 'method'
{
MenuItem masterItem = new MenuItem(masterRow("ModuleName").ToString());
//Error 2 'masterRow' is a 'variable' but is used like a 'method'
Menu1.Items.Add(masterItem);
foreach (System.Data.DataRow childRow in masterRow.GetChildRows("Children"))
{
MenuItem childItem = new MenuItem(childRow("FormName").ToString());
//Error 3 'childRow' is a 'variable' but is used like a 'method'
masterItem.ChildItems.Add(childItem);
}
}
}
public System.Data.DataSet GetMenuData()
{
System.Data.SqlClient.
SqlConnection con = new System.Data.SqlClient.SqlConnection(connectionString);
System.Data.SqlClient.
SqlDataAdapter dadCats = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM tblModules", con);
System.Data.SqlClient.
SqlDataAdapter dadProducts = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM tblForms", con);
System.Data.
DataSet dst = new System.Data.DataSet();
dadCats.Fill(dst,
"Module");
dadProducts.Fill(dst,
"Form");
dst.Relations.Add(
"Children", dst.Tables("Module").Columns("ModuleID"), dst.Tables("Form").Columns("ModuleID"));
//Error 4 'System.Data.DataSet.Tables' is a 'property' but is used like a 'method'
//Error 5 'System.Data.DataSet.Tables' is a 'property' but is used like a 'method'
return dst;
}