Example #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);
        }
Example #2
0
        public bool InitializeDatabase()
        {
            if (String.IsNullOrWhiteSpace(KeyIdentifier))
            {
                return(false);
            }

            _dbConn = new AmcDataConnection()
            {
                ConnectionString = ConnectionString,
                TableName        = TableName,
                DataBaseType     = DataBaseType,
                KeyIdentifier    = KeyIdentifier,
                KeyValue         = KeyValue,
                WhereClause      = GetWhereSQL()
            };

            //_dbConn.WhereClause = GetWhereSQL() + AddVersionToWhere();

            // ja - connect to a table
            if (!_dbConn.ConnectToDatabase())
            {
                return(false);
            }

            AddColumns();

            if (_ColumnNames.Count > 0)
            {
                Found = _dbConn.FillTable(_ColumnNames);
            }
            else
            {
                Found = _dbConn.FillTable();
            }

            return(true);
        }