コード例 #1
0
        private static bool FindLasestVersionForTable(string sPartNumber, string sTableName, ref string sVersion)
        {
            string sConn             = @"Data Source=\\BOA\Production\Prodman.vfp\DATABASE\" + sTableName + ".dbf;" + @"Provider=VFPOLEDB.1;";
            string sFormattedPartNum = AmcDataConnection.QUOTE + sPartNumber + AmcDataConnection.QUOTE;

            AmcDataConnection vfpTempConn = new AmcDataConnection()
            {
                DataBaseType     = (int)dbType.vfp,
                TableName        = sTableName,
                ConnectionString = sConn
            };

            if (vfpTempConn.ConnectToDatabase())
            {
                string          sSelectSql = "select top 1 partnumber, version from " + vfpTempConn.TableName + " where Partnumber" + " = " + sFormattedPartNum + " ORDER BY version descending";
                OleDbCommand    cmdSelect  = new OleDbCommand(sSelectSql, vfpTempConn.GetOleConn());
                OleDbDataReader rdr        = cmdSelect.ExecuteReader();

                if (rdr.HasRows)
                {
                    rdr.Read();

                    sVersion = rdr["version"].ToString();

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public bool PerformUpdate()
        {
            Console.WriteLine("PerformUpdate");
            bool bRet = true;

            GenerateUpdateSQLString();

            OleDbCommand SQlUpdate = new OleDbCommand(UpdateString, _dbConn.GetOleConn());

            // ja - don't catch the exception here, let the UI do it
            try
            {
                if (SQlUpdate.ExecuteNonQuery() == -1)
                {
                    bRet = false;
                    throw new System.ArgumentException("Update Failed", "AMCDatabase");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new System.ArgumentException(ex.Message, "AMCDatabase");
            }

            return(bRet);
        }