Click here to Skip to main content
15,921,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wrote this function to set the member status but its not checking the 3rd and 4th condtion please check and tell me where i go wrong???





private void BindCheck(string code)
{
// SqlConnection con = new SqlConnection("");
SqlConnection con = new SqlConnection("");

con.Open();
string query = "SELECT * FROM Registration_Master WHERE regCode= '" + code + "'";

com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt = new DataTable();
da.Fill(dt);

try
{
if (dt.Rows.Count > 0)
{
BindCheck(dt.Rows[0]["sponcorid"].ToString());
int count_mem = Convert.ToInt32(dt.Rows[0]["count_mem"]);
count_mem++;
com = new SqlCommand();
com.Connection = con;
com.CommandText = "UPDATE Registration_Master SET count_mem = '" + count_mem + "' ,modifieddate='" + DateTime.Now + "' WHERE regCode = '" + code + "'";
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();


if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 20)
{
query = "UPDATE Registration_Master SET member_status= 'MANAGER' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
else if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 40)
{
query = "UPDATE Registration_Master SET member_status= 'CHIEF MANAGER' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}

else if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 60)
{
query = "UPDATE Registration_Master SET member_status= 'DIRECTOR' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}



}
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
Posted
Updated 5-Nov-12 23:52pm
v2

1 solution

Hi
If (x >20 && x<=40)
{
Some Statements
}

IF (x>40 && x<=60)
{
Some Statements
}

try this....!!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900