Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 5-Nov-12 19:00pm
Edited 6-Nov-12 0:52am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi
 
If (x >20 && x<=40)
{
Some Statements
}
 
IF (x>40 && x<=60)
{
Some Statements
}
 
try this....!!!!
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.150305.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100