Click here to Skip to main content

arvindnitin7 asked:

Open original thread
int a;
        private void button2_Click(object sender, EventArgs e)
        {
            //comboBox1.Items.Add(comboBox1.Text);
            string val = textBox10.Text.ToString();
            if (val == "")
            {
                textBox10.Text = "1";
            }
            else
            {
                
                a = Convert.ToInt32(textBox10.Text.ToString());
                a = a + 1;
                textBox10.Text = a.ToString();
                //}
            }
            string cmdtext = "insert into ITEM(ITEM_ID,ITEM_INNER_D,ITEM_OUTER_D,ITEM_NAME,ITEM_UNIT,ITEM_PRI_MEAS_UNIT,ITEM_SEC_MEAS_UNIT,ITEM_TYPE,ITEM_COLOR,ITEM_WR,ITEM_RAW,ITEM_FINISH,ITEM_MATERIAL,ITEM_IG_ID) values('" + textBox10.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox7.Text + "','" + textBox6.Text + "','" + comboBox4.SelectedItem + "','" + comboBox1.SelectedItem + "','" + checkBox1.Checked + "','" + textBox8.Text + "','" + textBox9.Text + "','" + comboBox3.SelectedItem + "','" + textBox5.Text + "')";
            //string cmdtext = "insert into ACCOUNT(ACC_ID,ACC_NAME,ACC_TYPE,ACC_ADD1) VALUES ('" + textBox17.Text + "','" + textBox1.Text + "','" + comboBox1.SelectedItem + "','" + richTextBox1.Text + "')";
            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TWPLSOFTWARE;Integrated Security=True");
            SqlCommand cmd = new SqlCommand(cmdtext, con);
            try
            {
                //if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox9.Text != "" && textBox10.Text != "" && textBox11.Text != "")
                if (textBox1.Text == "")
                {
                    MessageBox.Show("PLEASE FILL ALL ENTRIES");
                    
 
                }
                
                else
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show(" Data Sucessfully Inserted");
                    textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = "";textBox4.Text = ""; textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";comboBox1.text="";comboBox3.text="";comboBox4.text="";
                    
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }
        }
 
[edit]Code block added - OriginalGriff[/edit]
Tags: C#

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100