Sousa Pambo

Sousa Pambo

  • NA
  • 92
  • 24.2k

ERROR: Method name expected

Nov 17 2016 6:57 AM
 Hi, i get this error ,Method name expected, when I write this code, please help
 
public string MonthP(string student_id, int y, string mth)
{
string sql = "Select sitS from Sit where student_id='" + id + "' and years='" + (y).ToString() + "'";
using (SqlConnection cn = new SqlConnection(con.stringConex()))
{
try
{
cn.Open();
using (SqlCommand cm = new SqlCommand(sql, cn))
{
using (SqlDataReader rd = cm.ExecuteReader())
{
if (rd.Read())
{
return rd["sitS "](Convert.ToInt32(mth) - 1); // Error on this line
}
else
{
return "-1";
}
}
}
}
catch (Exception ex)
{
return "-1";
}
}
}
 
Thanks! 

Answers (4)