Exemplo n.º 1
0
        // Get an object by Object ID.
        public static c_object GetObject(int ObjectID)
        {
            c_object oObject = new c_object();

            // Configure database connection elements.
            OleDbDataAdapter da         = new OleDbDataAdapter();
            OleDbConnection  connection = new OleDbConnection();

            connection.ConnectionString = database.getConnectionString();
            DataSet ds = new DataSet("object");

            try
            {
                connection.Open();

                // Create query.
                string strSQL = string.Empty;
                strSQL += " select [ObjectID], [VNUM], [ShortDesc], [ObjectType] ";
                strSQL += " from   [Object] ";
                strSQL += " where  ObjectID = " + ObjectID + " ";

                da = new OleDbDataAdapter(strSQL, connection);
                da.Fill(ds);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    oObject.objectID  = (int)ds.Tables[0].Rows[0]["ObjectID"];
                    oObject.objVNUM   = (int)ds.Tables[0].Rows[0]["VNUM"];
                    oObject.ShortDesc = (string)ds.Tables[0].Rows[0]["ShortDesc"];
                    oObject.objType   = (string)ds.Tables[0].Rows[0]["ObjectType"];
                }
            }
            catch (Exception ex)
            {
                string strError = ex.Message;
            }

            connection.Close();
            connection.Dispose();

            return(oObject);
        }
Exemplo n.º 2
0
        // Get an object by Object ID.
        public static c_object GetObject(int ObjectID)
        {
            c_object oObject = new c_object();

            // Configure database connection elements.
            OleDbDataAdapter da = new OleDbDataAdapter();
            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = database.getConnectionString();
            DataSet ds = new DataSet("object");

            try
            {
                connection.Open();

                // Create query.
                string strSQL = string.Empty;
                strSQL += " select [ObjectID], [VNUM], [ShortDesc], [ObjectType] ";
                strSQL += " from   [Object] ";
                strSQL += " where  ObjectID = " + ObjectID + " ";

                da = new OleDbDataAdapter(strSQL, connection);
                da.Fill(ds);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    oObject.objectID = (int)ds.Tables[0].Rows[0]["ObjectID"];
                    oObject.objVNUM = (int)ds.Tables[0].Rows[0]["VNUM"];
                    oObject.ShortDesc = (string)ds.Tables[0].Rows[0]["ShortDesc"];
                    oObject.objType = (string)ds.Tables[0].Rows[0]["ObjectType"];
                }
            }
            catch (Exception ex)
            {
                string strError = ex.Message;
            }

            connection.Close();
            connection.Dispose();

            return oObject;
        }