Click here to Skip to main content

sumit kausalye asked:

Open original thread
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();
}
}
Tags: C#

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
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