请检查查询 [英] Please Check the query
问题描述
我编写了此函数来设置成员状态,但是它没有检查第3和第4个条件,请检查并告诉我我哪里出错了???
私有void BindCheck(字符串代码)
{
//SqlConnection con = new SqlConnection(");
SqlConnection con =新的SqlConnection(");
con.Open();
字符串查询="SELECT * FROM Registration_Master WHERE regCode =""+代码+"";
com = new SqlCommand(query,con);
com.CommandType = CommandType.Text;
SqlDataAdapter da =新的SqlDataAdapter(com);
DataTable dt = new DataTable();
da.Fill(dt);
试试
{
如果(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 =""+代码+"";
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
如果(Convert.ToInt32(dt.Rows [0] ["count_mem"])> 20)
{
query ="UPDATE Registration_Master SET member_status =``MANAGER'',modifieddate =''" + DateTime.Now +''WHERE regCode =''" +代码+''";
com = new SqlCommand(query,con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
否则,如果(Convert.ToInt32(dt.Rows [0] ["count_mem"])> 40)
{
query ="UPDATE Registration_Master SET member_status ="首席经理,modifieddate =''" + DateTime.Now +''WHERE regCode =""+代码+"";
com =新的SqlCommand(query,con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
否则,如果(Convert.ToInt32(dt.Rows [0] ["count_mem"])> 60)
{
query ="UPDATE Registration_Master SET member_status =``DIRECTOR'',modifieddate =''" + DateTime.Now +''WHERE regCode ="" +代码+''";
com =新的SqlCommand(query,con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
}
}
catch(ex ex例外)
{
扔前;
}
终于
{
con.Close();
}
}
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();
}
}
推荐答案
嗨
如果(x> 20 && x< = 40)
{
一些声明
}
IF(x> 40 && x <= 60)
{
一些声明
}
试试这个.... !!!!
Hi
If (x >20 && x<=40)
{
Some Statements
}
IF (x>40 && x<=60)
{
Some Statements
}
try this....!!!!
这篇关于请检查查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!