public DataSet ds = new DataSet();
public SqlDataAdapter adapter = new SqlDataAdapter();
public int AuthenticatedUserAge(String User_name)
{
string sql = "SELECT UserName, Age FROM tblDataProg WHERE (UserName ='" + User_name + "')";
ds = GetDataSet(sql);
int help = int.Parse(ds.Tables[0].Rows[0]["Age"].ToString());
return help;
}
public DataSet GetDataSet(string sql)
{
SqlConnection connection = new SqlConnection(ConnStr());
SqlCommand cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = connection;
adapter = new SqlDataAdapter(cmd);
connection.Open();
adapter.Fill(ds);
connection.Close();
return ds;
}
public string ConnStr()
{
return @"Data Source=.\SQLEXPRESS;AttachDbFilename='G:\עבודת גמר תכנות\v5\חדש תיקיה 1\v4\App_Data\SiteDB.mdf';Integrated Security=True;User Instance=True";
}
I need to check that the value that is returned from AuthenticatedUserAge
is a number less than 17 that it will write hello teenager else write hello adult.
The problem I think is this line doesn't return a value:
int help = int.Parse(ds.Tables[0].Rows[0]["Age"].ToString());
it throws this error:
Input string was not in a correct format