コード例 #1
0
ファイル: FrmProduct.cs プロジェクト: ricct/cdbcsystemsample
        private void GetData()
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            if (!isNew)
            {
                CdbcConnection con = UtilCommon.getConnection();

                string cmdQuery = "SELECT P.PRODUCT_CODE "
                                  + "     , P.PRODUCT_NAME "
                                  + "     , P.PRODUCT_PRICE "
                                  + "     , P.CURRENCY_CODE "
                                  + "     , P.PRODUCT_SUMMARY "
                                  + "     , P.CATEGORY_CODE "
                                  + "     , P.PRODUCT_IMAGE "
                                  + "     , P.RELEASE_DATE "
                                  + "  FROM PRODUCTS P "
                                  + " WHERE P.PRODUCT_CODE = :PRODUCT_CODE ";

                CdbcCommand cmd = new CdbcCommand(cmdQuery);

                cmd.Connection  = con;
                cmd.CommandType = CommandType.Text;

                CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
                para.Value = ProductCode;
                cmd.Parameters.Add(para);

                DataSetProducts dsProduct = new DataSetProducts();
                CdbcDataAdapter myDa      = new CdbcDataAdapter(cmd);
                try
                {
                    myDa.Fill(dsProduct, dsProduct.PRODUCTS.TableName);
                    if (dsProduct.Tables.Count > 0 && dsProduct.Tables[0].Rows.Count > 0)
                    {
                        DataSetProducts.PRODUCTSRow dr = (DataSetProducts.PRODUCTSRow)dsProduct.PRODUCTS.Rows[0];
                        txtProductName.Text      = UtilCommon.NvlStr(dr.PRODUCT_NAME);
                        txtPrice.Text            = UtilCommon.NvlStr(dr.PRODUCT_PRICE);
                        cbCurrency.SelectedValue = UtilCommon.NvlStr(dr.CURRENCY_CODE);
                        txtSummary.Text          = UtilCommon.NvlStr(dr.PRODUCT_SUMMARY);
                        cbCategory.SelectedValue = UtilCommon.NvlStr(dr.CATEGORY_CODE);
                        dtReleaseDate.Value      = dr.RELEASE_DATE;
                        pictureBox1.Image        = UtilCommon.ByteArrayToImage(dr.PRODUCT_IMAGE);
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message,
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error)
                    ;
                }
            }
            sw.Stop();
            this.Text = $"{sw.ElapsedMilliseconds} ms";
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string imageType = Page.Request.QueryString.Get("imagetype");
            string code      = Page.Request.QueryString.Get("code");

            if (String.IsNullOrEmpty(imageType) || String.IsNullOrEmpty(code))
            {
                Response.End();
                return;
            }

            string cmdQuery = "";

            if (imageType == "product")
            {
                cmdQuery = " SELECT P.PRODUCT_IMAGE "
                           + "  FROM PRODUCTS P "
                           + " WHERE P.PRODUCT_CODE=:PRODUCT_CODE";
            }

            Response.ContentType = "image";
            Response.Flush();

            if (!String.IsNullOrEmpty(cmdQuery))
            {
                CdbcConnection con = UtilCommon.getConnection();

                CdbcCommand cmd = new CdbcCommand(cmdQuery);
                cmd.Connection  = con;
                cmd.CommandType = CommandType.Text;

                CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
                para.Value = code;
                cmd.Parameters.Add(para);

                CdbcDataAdapter dataAdapter = new CdbcDataAdapter(cmd);
                DataSet         dsProduct   = new DataSet();

                try
                {
                    dataAdapter.Fill(dsProduct, "PRODUCTS");
                    if (dsProduct.Tables.Count > 0 && dsProduct.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = dsProduct.Tables[0].Rows[0];

                        byte[] bImage = (byte[])(dr["PRODUCT_IMAGE"]);
                        Response.OutputStream.Write(bImage, 0, bImage.Length);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //Please treat the exception here
                }
            }

            Response.End();
        }
コード例 #3
0
        private void GvProdList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == colBtnEdit.Index)
            {
                DataGridViewRow row        = this.gvProdList.Rows[e.RowIndex];
                FrmProduct      frmProduct = new FrmProduct();
                frmProduct.isNew = false;
                frmProduct.dsCategoriesCurrencies = (DataSetProducts)this.dsCategoriesCurrencies.Copy();
                frmProduct.ProductCode            = row.Cells[colProductCode.Index].Value.ToString();
                this.Hide();
                frmProduct.ShowDialog();
                if (frmProduct.dataSaved)
                {
                    GetProductList();
                }
                frmProduct.Dispose();
                this.Show();
            }
            else if (e.ColumnIndex == colBtnDelete.Index)
            {
                DialogResult result = MessageBox.Show("Are you sure to delete?",
                                                      "Confirm",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);

                if (result != DialogResult.Yes)
                {
                    return;
                }

                DataGridViewRow row         = this.gvProdList.Rows[e.RowIndex];
                String          productcode = row.Cells[colProductCode.Index].Value.ToString();

                String cmdQuery = @"DELETE FROM PRODUCTS WHERE PRODUCT_CODE=:PRODUCT_CODE";

                CdbcConnection con = UtilCommon.getConnection();
                CdbcCommand    cmd = new CdbcCommand(cmdQuery, con);

                CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", CdbcOracleDbType.Varchar2);
                para.Value = productcode;
                cmd.Parameters.Add(para);
                try
                {
                    cmd.ExecuteNonQuery();
                    GetProductList();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message,
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error)
                    ;
                }
            }
        }
コード例 #4
0
        private void GetProductDetail()
        {
            bool           hasProduct  = false;
            String         productcode = Request.QueryString["productcode"];
            CdbcConnection con         = UtilCommon.getConnection();

            string cmdQuery = "SELECT P.PRODUCT_CODE "
                              + "     , P.PRODUCT_NAME "
                              + "     , P.PRODUCT_PRICE "
                              + "     , P.CURRENCY_CODE "
                              + "     , P.PRODUCT_SUMMARY "
                              + "     , P.CATEGORY_CODE "
                              + "     , P.PRODUCT_IMAGE "
                              + "     , P.RELEASE_DATE "
                              + "  FROM PRODUCTS P "
                              + " WHERE P.PRODUCT_CODE = :PRODUCT_CODE ";

            CdbcCommand cmd = new CdbcCommand(cmdQuery);

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;

            CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);

            para.Value = productcode;
            cmd.Parameters.Add(para);

            DataSet         dsProduct = new DataSet();
            CdbcDataAdapter myDa      = new CdbcDataAdapter(cmd);

            try
            {
                myDa.Fill(dsProduct, "PRODUCT");
                if (dsProduct.Tables.Count > 0 && dsProduct.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsProduct.Tables[0].Rows[0];
                    lblProductName.Text = UtilCommon.NvlStr(dr["PRODUCT_NAME"]);
                    lblPrice.Text       = UtilCommon.NvlStr(dr["CURRENCY_CODE"]) + UtilCommon.FormatNumber(dr["PRODUCT_PRICE"]);
                    lblDescription.Text = UtilCommon.NvlStr(dr["PRODUCT_SUMMARY"]);
                    lblReleaseDate.Text = UtilCommon.NvlStr(dr["RELEASE_DATE"]);
                    imageProduct.Src    = @"./ShowImage?imagetype=product&code=" + UtilCommon.NvlStr(dr["PRODUCT_CODE"]);
                    hasProduct          = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //Please treat the exception here
            }

            if (!hasProduct)
            {
                Response.Redirect("./Default");
            }
        }
コード例 #5
0
        public static void DataAdapter_Fill_Sample()
        {
            Console.WriteLine(String.Format("{0} DataAdapter_Fill_Sample", databaseProductType.ToString()));

            Console.WriteLine("Start");

            CdbcConnection con      = UtilCommon.getConnection(databaseProductType);
            string         queryStr = "SELECT :VAR1 AS COLUMN1 FROM DUAL";
            CdbcCommand    cmd      = new CdbcCommand(queryStr, con);

            string        guid = Guid.NewGuid().ToString();
            CdbcParameter para = new CdbcParameter(":VAR1", CdbcOracleDbType.Varchar2);

            para.Direction = ParameterDirection.Input;
            para.Value     = guid;
            cmd.Parameters.Add(para);

            try
            {
                CdbcDataAdapter adap = new CdbcDataAdapter(cmd);
                DataSet         ds   = new DataSet();
                adap.Fill(ds);

                Console.WriteLine("--------------------------");
                Console.WriteLine("Sql : " + queryStr);
                Console.WriteLine("Parameter : VAR1=" + guid);
                Console.WriteLine("--------------------------");

                Console.WriteLine("Expected value:" + guid);

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    Console.WriteLine("Actual value:" + ds.Tables[0].Rows[0][0]);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("--------------------------");
            Console.WriteLine("End");
        }
コード例 #6
0
        public static void Command_ExecuteScalar_Sample()
        {
            Console.WriteLine(String.Format("{0} Command_ExecuteScalar_Sample", databaseProductType.ToString()));

            Console.WriteLine("Start");

            CdbcConnection con      = UtilCommon.getConnection(databaseProductType);
            string         queryStr = @"SELECT :VAR1 AS A FROM DUAL";
            CdbcCommand    cmd      = new CdbcCommand(queryStr, con);

            string guid = Guid.NewGuid().ToString();

            CdbcParameter para = new CdbcParameter(":VAR1", CdbcOracleDbType.Varchar2);

            para.Value = guid;
            cmd.Parameters.Add(para);


            Console.WriteLine("--------------------------");
            Console.WriteLine("Sql : " + queryStr);
            Console.WriteLine("Parameter : VAR1=" + guid);
            Console.WriteLine("--------------------------");

            try
            {
                object o = cmd.ExecuteScalar();
                Console.WriteLine("Expected value:" + guid);
                Console.WriteLine("Actual value:" + o.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("--------------------------");
            Console.WriteLine("End");
        }
コード例 #7
0
        public static void DataAdapter_Update_Sample()
        {
            Console.WriteLine(String.Format("{0} DataAdapter_Update_Sample", databaseProductType.ToString()));
            Console.WriteLine("Start");
            Console.WriteLine("This sample will show you how to use CdbcDataAdapter.update insert ,update and delete data.");

            string guid = Guid.NewGuid().ToString();

            CdbcConnection con = UtilCommon.getConnection(databaseProductType);


            try
            {
                //Sample 1 :Add new row (insert)
                Console.WriteLine("--------------------------");
                Console.WriteLine("Sample 1 : Insert a record into table CODE_SAMPLE");
                Console.WriteLine("--------------------------");

                string             queryStrInsert = @"SELECT VAR1,NUM1,DATE1,CLOB1,BLOB1 FROM CODE_SAMPLE WHERE VAR1=:VAR1";
                CdbcCommand        cmdInsert      = new CdbcCommand(queryStrInsert, con);
                CdbcDataAdapter    adapInsert     = new CdbcDataAdapter(cmdInsert);
                CdbcCommandBuilder cb             = new CdbcCommandBuilder(adapInsert);
                DataTable          dt1            = new DataTable();


                adapInsert.FillSchema(dt1, SchemaType.Mapped);

                DataRow dr1 = dt1.NewRow();
                dr1["VAR1"]  = guid;
                dr1["NUM1"]  = DateTime.Now.Second;
                dr1["DATE1"] = DateTime.Now;
                dr1["CLOB1"] = "testclob";
                //  dr1["BLOB1"] = System.IO.File.ReadAllBytes(@"your file path");
                dt1.Rows.Add(dr1);
                int i = adapInsert.Update(dt1);
                Console.WriteLine(String.Format("{0} Line(s) inserted.", i));


                //Sample 2 :Edit row data (update)

                Console.WriteLine("--------------------------");
                Console.WriteLine("Sample 2 : update the record we inserted before.");
                Console.WriteLine("--------------------------");

                string        queryStrUpdate = @"SELECT VAR1,NUM1,DATE1,CLOB1,BLOB1 FROM CODE_SAMPLE WHERE VAR1=:VAR1";
                CdbcCommand   cmdUpdate      = new CdbcCommand(queryStrUpdate, con);
                CdbcParameter para           = new CdbcParameter(":VAR1", CdbcOracleDbType.Varchar2);
                para.Value = guid;
                cmdUpdate.Parameters.Add(para);

                CdbcDataAdapter    adapUpdate = new CdbcDataAdapter(cmdUpdate);
                CdbcCommandBuilder cbUpdate   = new CdbcCommandBuilder(adapUpdate);
                DataSet            dsUpdate   = new DataSet();
                adapUpdate.Fill(dsUpdate);
                dsUpdate.Tables[0].Rows[0]["NUM1"]  = DateTime.Now.Second;
                dsUpdate.Tables[0].Rows[0]["DATE1"] = DateTime.Now;

                i = adapUpdate.Update(dsUpdate, dsUpdate.Tables[0].TableName);

                Console.WriteLine(String.Format("{0} Line(s) updated.", i));

                //Sample 3 :Delete row  (delete)
                Console.WriteLine("--------------------------");
                Console.WriteLine("Sample 3 : Delete the record we inserted before.");
                Console.WriteLine("--------------------------");

                DataSet dsDelete = new DataSet();
                adapUpdate.Fill(dsDelete);
                dsDelete.Tables[0].Rows[0].Delete();
                i = adapUpdate.Update(dsDelete.Tables[0]);
                //The following code will have same result.
                //i = adapUpdate.Update(dsDelete, dsDelete.Tables[0].TableName);

                Console.WriteLine(String.Format("{0} Line(s) Deleted.", i));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("end");
        }
コード例 #8
0
        public static void Command_ExecuteNonQuery_Sample()
        {
            Console.WriteLine(String.Format("{0} Command_ExecuteNonQuery_Sample", databaseProductType.ToString()));

            Console.WriteLine("Start");

            CdbcConnection con      = UtilCommon.getConnection(databaseProductType);
            string         queryStr = @"INSERT INTO CODE_SAMPLE(VAR1, NUM1, DATE1, CLOB1, BLOB1) VALUES (:VAR1, :NUM1, :DATE1, :CLOB1, :BLOB1)";
            CdbcCommand    cmd      = new CdbcCommand(queryStr, con);

            string guid = Guid.NewGuid().ToString();

            CdbcParameter para = new CdbcParameter(":VAR1", CdbcOracleDbType.Varchar2);

            para.Value = guid;
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":NUM1", CdbcOracleDbType.Decimal);
            para.Value = DateTime.Now.Second;
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":DATE1", CdbcOracleDbType.Date);
            para.Value = DateTime.Now;
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":CLOB1", CdbcOracleDbType.Clob);
            para.Value = DateTime.Now.Second;
            cmd.Parameters.Add(para);

            para = new CdbcParameter(":BLOB1", CdbcOracleDbType.Blob);
            //para.Value = System.IO.File.ReadAllBytes(@"your file path");
            cmd.Parameters.Add(para);


            Console.WriteLine("--------------------------");
            Console.WriteLine("Sample 1 : Insert a record into table CODE_SAMPLE");
            Console.WriteLine("Sql : " + queryStr);

            try
            {
                int i = cmd.ExecuteNonQuery();

                Console.WriteLine(String.Format("{0} Line(s) inserted.", i));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }


            string      queryStrDelete = @"DELETE FROM CODE_SAMPLE WHERE VAR1=:VAR1";
            CdbcCommand cmdDelete      = new CdbcCommand(queryStrDelete, con);

            para       = new CdbcParameter(":VAR1", CdbcOracleDbType.Varchar2);
            para.Value = guid;
            cmdDelete.Parameters.Add(para);


            Console.WriteLine("--------------------------");
            Console.WriteLine("Sample 2 : Delete the record we inserted before.");
            Console.WriteLine("Sql : " + queryStrDelete);

            try
            {
                int i = cmdDelete.ExecuteNonQuery();

                Console.WriteLine(String.Format("{0} Line(s) deleted.", i));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("--------------------------");
            Console.WriteLine("End");
        }
コード例 #9
0
        public static void CommandCollection_ExecuteMultiQuery_Sample()
        {
            Console.WriteLine(String.Format("{0} CommandCollection_ExecuteMultiQuery_Sample", databaseProductType.ToString()));
            Console.WriteLine("Start");

            Console.WriteLine("--------------------------");
            Console.WriteLine("CommandCollection.ExecuteMultiQuery is original Method of CdbcCommandCollection.");
            Console.WriteLine("It can execute multi command in same transaction.");
            Console.WriteLine("It is designed to improve performance and Data Concurrency and Consistency");
            Console.WriteLine("--------------------------");
            Console.WriteLine("This sample will insert 3 records and than update one of the record.");
            Console.WriteLine("--------------------------");

            CdbcConnection con       = UtilCommon.getConnection(databaseProductType);
            string         queryStr1 = @"INSERT INTO CODE_SAMPLE(VAR1 , DATE1 ) VALUES (:VAR1, SYSDATE)";
            CdbcCommand    cmd1      = new CdbcCommand(queryStr1, con);

            string[] arrParas = new string[3];

            for (int i = 0; i < arrParas.Length; i++)
            {
                arrParas[i] = Guid.NewGuid().ToString();
            }

            cmd1.ArrayBindCount = 3;
            CdbcParameter prm =
                new CdbcParameter("VAR1", CdbcOracleDbType.Varchar2);

            prm.Value = arrParas;
            cmd1.Parameters.Add(prm);

            string      queryStr2 = @"UPDATE CODE_SAMPLE SET DATE1 = DATE1+1 WHERE VAR1=:VAR1";
            CdbcCommand cmd2      = new CdbcCommand(queryStr2, con);

            prm       = new CdbcParameter("VAR1", CdbcOracleDbType.Varchar2);
            prm.Value = arrParas[0];
            cmd2.Parameters.Add(prm);


            Console.WriteLine("--------------------------");
            Console.WriteLine("SQL 1 :" + queryStr1);
            Console.WriteLine("Para 1 :");

            for (int i = 0; i < arrParas.Length; i++)
            {
                Console.WriteLine(arrParas[i]);
            }
            Console.WriteLine("");
            Console.WriteLine("SQL 2 :" + queryStr2);

            Console.WriteLine("--------------------------");
            try
            {
                CdbcCommandCollection cmdCollection = new CdbcCommandCollection();
                cmdCollection.Add(cmd1);
                cmdCollection.Add(cmd2);
                cmdCollection.ExecuteMultiQuery();

                for (int iCmd = 0; iCmd < cmdCollection.Count; iCmd++)
                {
                    Console.WriteLine(String.Format("Command {0} Result : {1} ", iCmd, cmdCollection.ExecuteNonQueryResult[iCmd].ToString()));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }

            //Confirm Data
            Console.WriteLine("---Confirm Data-----------------------");
            string      queryStrSelect = @"SELECT VAR1, DATE1 FROM CODE_SAMPLE WHERE VAR1 IN (:VAR1_0 ,:VAR1_1,:VAR1_2) ";
            CdbcCommand cmdSelect      = new CdbcCommand(queryStrSelect, con);

            for (int i = 0; i < arrParas.Length; i++)
            {
                prm       = new CdbcParameter("VAR1_" + i.ToString(), CdbcOracleDbType.Varchar2);
                prm.Value = arrParas[i];
                cmdSelect.Parameters.Add(prm);
            }

            try
            {
                DbDataReader reader = cmdSelect.ExecuteReader();
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        Console.WriteLine(String.Format("{0} = {1}", reader.GetName(i), reader.GetValue(i).ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }

            //Clear Data
            Console.WriteLine("---Clear Data-----------------------");

            string      queryStrDelete = @"DELETE FROM CODE_SAMPLE WHERE VAR1=:VAR1";
            CdbcCommand cmdDelete      = new CdbcCommand(queryStrDelete, con);

            cmdDelete.ArrayBindCount = 3;
            prm =
                new CdbcParameter("VAR1", CdbcOracleDbType.Varchar2);
            prm.Value = arrParas;
            cmdDelete.Parameters.Add(prm);
            try
            {
                int i = cmdDelete.ExecuteNonQuery();

                Console.WriteLine(String.Format("{0} Line(s) Deleted.", i));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:");
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("--------------------------");
            Console.WriteLine("End");
        }
コード例 #10
0
ファイル: FrmProduct.cs プロジェクト: ricct/cdbcsystemsample
        private bool SaveData()
        {
            CdbcConnection con = UtilCommon.getConnection();
            string         cmdQuery;

            if (isNew)
            {
                cmdQuery = @"INSERT INTO PRODUCTS("
                           + "    PRODUCT_NAME"
                           + "  , PRODUCT_PRICE"
                           + "  , CURRENCY_CODE"
                           + "  , PRODUCT_SUMMARY"
                           + "  , CATEGORY_CODE"
                           + "  , PRODUCT_IMAGE"
                           + "  , RELEASE_DATE"
                           + "  , PRODUCT_CODE"
                           + " ) "
                           + "VALUES ("
                           + "    :PRODUCT_NAME"
                           + "  , :PRODUCT_PRICE"
                           + "  , :CURRENCY_CODE"
                           + "  , :PRODUCT_SUMMARY"
                           + "  , :CATEGORY_CODE"
                           + "  , :PRODUCT_IMAGE"
                           + "  , :RELEASE_DATE"
                           + "  , :PRODUCT_CODE"
                           + ")";
            }
            else
            {
                cmdQuery = @"UPDATE PRODUCTS "
                           + " SET PRODUCT_NAME    = :PRODUCT_NAME"
                           + "  ,  PRODUCT_PRICE   = :PRODUCT_PRICE"
                           + "  ,  CURRENCY_CODE   = :CURRENCY_CODE"
                           + "  ,  PRODUCT_SUMMARY = :PRODUCT_SUMMARY"
                           + "  ,  CATEGORY_CODE   = :CATEGORY_CODE"
                           + "  ,  PRODUCT_IMAGE   = :PRODUCT_IMAGE"
                           + "  ,  RELEASE_DATE    = :RELEASE_DATE"
                           + " WHERE PRODUCT_CODE  = :PRODUCT_CODE";
            }

            // Create the OracleCommand
            CdbcCommand cmd = new CdbcCommand(cmdQuery, con);

            CdbcParameter para = new CdbcParameter(":PRODUCT_NAME", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);

            para.Value = txtProductName.Text;
            cmd.Parameters.Add(para);

            para = new CdbcParameter(":PRODUCT_PRICE", Cdbc.Common.Data.Type.CdbcOracleDbType.Decimal);
            int iPrice;

            if (Int32.TryParse(txtPrice.Text, out iPrice))
            {
                para.Value = iPrice;
            }
            else
            {
                MessageBox.Show("Invalid price.",
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error)
                ;
                return(false);
            }
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":CURRENCY_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
            para.Value = cbCurrency.SelectedValue;
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":PRODUCT_SUMMARY", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
            para.Value = txtSummary.Text;
            cmd.Parameters.Add(para);


            para       = new CdbcParameter(":CATEGORY_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
            para.Value = cbCategory.SelectedValue;
            cmd.Parameters.Add(para);


            para       = new CdbcParameter(":PRODUCT_IMAGE", Cdbc.Common.Data.Type.CdbcOracleDbType.Blob);
            para.Value = UtilCommon.ImageToByteArray(pictureBox1.Image);
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":RELEASE_DATE", Cdbc.Common.Data.Type.CdbcOracleDbType.Date);
            para.Value = new DateTime(dtReleaseDate.Value.Year, dtReleaseDate.Value.Month, dtReleaseDate.Value.Day);
            cmd.Parameters.Add(para);

            para       = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
            para.Value = ProductCode;
            cmd.Parameters.Add(para);

            //if (!isNew)
            //{
            //    para = new CdbcParameter(":ISBN2", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2);
            //    para.Value = txtISBN.Text;
            //    cmd.Parameters.Add(para);
            //}


            try
            {
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message,
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error)
                ;
                return(false);
            }
        }