public static DataTable test(string code) { SqlConnection con = new SqlConnection("Data Source=SHILPA;Initial Catalog=TreeDB;Integrated Security=True"); SqlCommand com = new SqlCommand(); con.Open(); DataTable dt = new DataTable(); try { string queryRM = "SELECT * FROM Registration_Master WHERE sponcorid='" + code.ToString() + "'"; dt = DBHelper.SQLHelper.getTable(queryRM.ToString()); if (dt.Rows.Count > 0) { DataTable dtl = new DataTable(); string left = "SELECT * FROM Registration_Master WHERE side='LEFT'"; dtl = DBHelper.SQLHelper.getTable(left.ToString()); int count_mem = Convert.ToInt32(dtl.Rows[0]["count_mem"]); count_mem++; com.Connection = con; com.CommandText = "UPDATE Counter SET leftcount =" + count_mem + ""; com.CommandType = CommandType.Text; com.ExecuteNonQuery(); DataTable dtr = new DataTable(); string right = "SELECT * FROM Registration_Master WHERE side='RIGHT'"; dtr = DBHelper.SQLHelper.getTable(right.ToString()); if (dtr.Rows.Count > 0) { int count1 = Convert.ToInt32(dtr.Rows[0]["count_mem"]); count1++; com = new SqlCommand(); com.Connection = con; com.CommandText = "UPDATE Counter SET rightcount =" + count1 + ""; com.CommandType = CommandType.Text; com.ExecuteNonQuery(); } DataTable dtcount = new DataTable(); string query = "SELECT * FROM Counter"; dtcount = DBHelper.SQLHelper.getTable(query.ToString()); if (dtcount.Rows.Count > 0) { if (dtcount.Rows[0]["leftcount"] == dtcount.Rows[0]["rightcount"]) { int count2 = Convert.ToInt32(dtl.Rows[0]["count_mem"]); count2++; com = new SqlCommand(); com.Connection = con; com.CommandText = "UPDATE Counter SET sponcorcount = " + count2 + ""; com.CommandType = CommandType.Text; com.ExecuteNonQuery(); } } } } catch (Exception ex) { throw ex; } finally { con.Close(); } return dt; }
if
if (dt.Rows.Count > 0)
Rows.Count
0
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)