Nathan R

Nathan R

  • NA
  • 13
  • 15.9k

how to count the execution of a method

Mar 13 2014 5:37 AM
Sir,

Please help me.

I am in a function to send sms in c# windows application.

I want to count this string occurance and update the sms send phone number.

Please Provide me the code to count string occurance.

Here the function:-

private void frmSMS_Load(object sender, EventArgs e)
        {
            SqlDataReader rdr = null;
            string Phone = string.Empty;
            string Msg = string.Empty;
            string userID = "[email protected]";
            string Pswrd = "sms12345";
            try
            {
                string cnn = ConfigurationManager.ConnectionStrings["MSCon"].ToString();
                SqlConnection cn = new SqlConnection(cnn);
                cn.Open();
                SqlCommand cmd = new SqlCommand("Get_PatientPhoneNo", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {                  
                    Phone = rdr["PHONE"].ToString();
                    Msg = rdr["COMMENTS"].ToString();
                    string strCount=SendSMSUsingBS(userID, Pswrd, Phone, Msg);
                    if (strCount == "1")
                    {
                        string cnn1 = ConfigurationManager.ConnectionStrings["MSCon"].ToString();
                        SqlConnection cn1 = new SqlConnection(cnn);
                        cn.Open();
                        SqlCommand cmd1 = new SqlCommand("Update_Sms_Status", cn1);
                        cmd.CommandType = CommandType.StoredProcedure;
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        DataSet ds = new DataSet();
                        adapter.Fill(ds);
                    }
                }
               
               
               
              
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex + "SMS01", "SMS", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
  
        }



Answers (2)