Beispiel #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (CmbCountry.Text == "")
         {
             MessageBox.Show("Please select Country", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             CmbCountry.Focus();
             return;
         }
         con = new SqlConnection(cs.DBcon);
         con.Open();
         cmd = new SqlCommand("SELECT rtrim(ID), rtrim(Companyname),rtrim(RegNo),rtrim(Role), rtrim(Telephone),rtrim(Fax), rtrim(Mobile),rtrim(City), rtrim(Country) , rtrim(State), rtrim(Objective),rtrim(Date),rtrim(Code),rtrim(Mgr),rtrim(investorType),rtrim(TotalAssets),rtrim(PEratio),rtrim(Fee),rtrim(Staff) FROM dbo.Company where  Country = '" + CmbCountry.Text + "' order by CompanyName", con);
         rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         dataGridView2.Rows.Clear();
         while (rdr.Read() == true)
         {
             dataGridView2.Rows.Add(rdr[0], rdr[1], rdr[2], rdr[3], rdr[4], rdr[5], rdr[6], rdr[7], rdr[8], rdr[9], rdr[10], rdr[11], rdr[12], rdr[13], rdr[14], rdr[15], rdr[16], rdr[17], rdr[18]);
         }
         con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (CmbCountry.Text == "")
         {
             MessageBox.Show("Please select Country", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             CmbCountry.Focus();
             return;
         }
         con = new SqlConnection(cs.DBcon);
         con.Open();
         cmd = new SqlCommand("SELECT rtrim(ID), rtrim(Contactname),rtrim(Mob),rtrim(PostalCode), rtrim(City),rtrim(country), rtrim(State),rtrim(Title), rtrim(Role) , rtrim(Notes),rtrim(Company) FROM dbo.Contact where country = '" + CmbCountry.Text + "' order by contactName", con);
         rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         dataGridView2.Rows.Clear();
         while (rdr.Read() == true)
         {
             dataGridView2.Rows.Add(rdr[0], rdr[1], rdr[2], rdr[3], rdr[4], rdr[5], rdr[6], rdr[7], rdr[8], rdr[9], rdr[10]);
         }
         con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }