简单的

  终于知道知道怎样进行基本的增删改查了
if (comboBox1.Text != "" || comboBox2.Text != "")
            {
                 if (MessageBox.Show( "你确认要增加吗?", "提示消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                     string connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
                                   + "(ADDRESS=(PROTOCOL=TCP)(HOST=192.163.3.3)(PORT=15321)))"
                                   + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=cqdd)));"
                                   + "User Id=sa;Password=.;";
                    OracleConnection conn = new OracleConnection(connectionString);
                     try
                    {
                        conn.Open();
                        OracleCommand cmd = conn.CreateCommand();
                        cmd.Connection = conn;

                        cmd.CommandText = "select DH as 编号,ZJHM as 街道,ZJDZ as 楼层,MAPPOSX as 达到 from DB_114";
                        cmd.CommandType = CommandType.Text;
                        OracleDataAdapter date = new OracleDataAdapter();
                        date.SelectCommand = cmd;
                        DataSet ds = new DataSet();
                        OracleCommandBuilder bui = new OracleCommandBuilder(date);
                        date.Fill(ds, "DB_114");

                        DataRow drow = ds.Tables[0].NewRow();
                        drow[0] = comboBox1.Text;
                        drow[1] = comboBox2.Text;
                        ds.Tables[0].Rows.Add(drow);
                        date.Update(ds, "DB_114");

                         if (dataGridView1.Rows.Count != 0)
                        {
                            dataGridView2.DataSource = ds.Tables[ "DB_114"];
                        }
                        MessageBox.Show( "增加成功");
                        comboBox2.Text = "";
                        comboBox1.Text = "";
                        ds.Dispose();
                        cmd.Dispose();
                    }

                     catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                     finally
                    {
                        conn.Close();

                    }
                }
                 else
                {
                    comboBox2.Text = "";
                    comboBox1.Text = "";
                }
            }
             else
            {
                MessageBox.Show( "请在combox中输入你要增加的值!", "提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }

你可能感兴趣的:(编程,开发,职场,程序,休闲)