4
Answers

ERROR: Method name expected

Ask a question
 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)