Monday, 4 August 2014

ID Show in C#.Net


 private void IdShow()
        {
            try
            {
                string str = "Select ID from T_MakeInvoice Order By ID Desc";
                cbxID.Items.Clear();
                con = new OleDbConnection(dbCon());
                OleDbCommand cmd = new OleDbCommand(str, con);
                con.Open();
                OleDbDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (dr.IsDBNull(0) == false)
                    {
                        cbxID.Items.Add(dr.GetValue(0).ToString());

                    }
                    else
                    {
                        cbxID.Text = "No Items";
                    }
                }
                dr.Close();
                con.Close();
                cbxID.Text = "Select";
            }
            catch (Exception ex)
            {
                MessageBox.Show("No Drugs in Database.\n\n Enter Item Name and Price", "Enter New Item,Price", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbxID.Focus();
                rbnEntry.PerformClick();

            }
        }

No comments:

Post a Comment