Published by Noble on 17 Mar 2008

Java Console Input

I had been looking around for a long time on how to do simple input from the console in a Java application. I found the following code that has really helped me out greatly.
 

import java.util.Scanner;

public class InputExp
{
public static
void Main(String[] args)
{
String name;
int age;
Scanner in = new Scanner(System.in);

// Read single line from console, store into variable

name = in.nextLine();
age = in.nextLine();
in.Close();

// Print the results.

System.out.println(”Name: ” + name);
System.out.println(”Age: ” + age);
}
}  

Published by Noble on 07 Dec 2007

Locating The Windows Mail Message Store

When I upgraded to Windows Vista I was shocked that I could not select the items that I wanted to backup. I had to use the backup wizard that came with Windows Vista and let me tell you, it is nothing like what the backup software of XP and and back was. So, rather than going out and purchasing a backup program I decided that I would just use my CD/DVD software and select the files and folders that I wanted to backup.

All was good…  Until I could not find my messages for Windows Mail. I done some searching and figured out a way that you can find the exact path and folder that stuff lives in. Below is how you can determine where your Windows Mail message store is located.

You need to have Windows Mail running for this process.

  1. Select “Tools” from the menu bar
  2. Then select “Options”
  3. Then select the “Advanced” tab
  4. Click the “Maintenance” button
  5. Then click the “Store Folder” button

You will then be presented with a popup window that tells you where Windows Mail stores it messages and data.

 

Published by Noble on 05 Dec 2007

How To Work With dBASE III Files In C# .NET

I have had a devil of a time trying to figure out how the best way to work with legacy dBASE III database files from C# and .NET. The real trick was to be able to create a new database from within the managed environment. I found several code blocks that showed how to write/read already created databases.

I looked everywhere I could think of but I was not having much luck. My web searching skills are not the best but I feel like I gave it a good effort. I decided to try and do it myself. Below is a class which is the result of my efforts to creating and using dBASE III databases from within C#.NET:

 

// OLEDbAccess Class - Version 1.00
//
// This class will allow the user to create a new dBase compatible file and manipulate it. It does not allow for reading.
//
// Version 1.00 November 29, 2007 - Initial Release

// Syntax for Create Command
// ————————-
// CREATE TABLE tablename.dbf (fieldname Char(25)
// CREATE TABLE tablename.dbf (fieldname Int)

// Syntax for Insert Command
// ————————-
// INSERT INTO tablename.dbf VALUES(’hi’,1)

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;

namespace OLEDbAccess
{
    public class OLEDbAccess
    {

        private string dataSource;

        /// <summary>
        /// The full path to the folder the dBase tables are located in. DO NOT specify the name of a database.
        /// </summary>
        public string DataSourcePath
        {
            get { return dataSource; }
            set { dataSource = value; }
        }

        /// <summary>
        /// Use this method to create tables or insert, update, or delete rows from an existing table.
        /// </summary>
        /// <param name=”modCommand”>The sql string to pass to the method.</param>
        /// <returns>Returns true if successful.</returns>
        public Boolean DbCommand(string modCommand)
        {
            if (ModifyTable(OpenDataConnection(), modCommand))
                return true;
            else
                return false;
        }

        // Open a database base connection via Ole.
        private OleDbConnection OpenDataConnection()
        {
            OleDbConnection conn = null;

            try
            {
                conn = new OleDbConnection(@”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + DataSourcePath + “;Extended Properties=DBase III;”);
                conn.Open();
                return conn;
            }
            catch (OleDbException odbe)
            {
                Console.WriteLine(”OleDbException: {0}”, odbe.Message);
                return null;
            }
        }

        // Close an existing open Ole database connection.
        private void CloseDataConnection(OleDbConnection conn)
        {
            if (conn.State == System.Data.ConnectionState.Open)
                conn.Close();
        }

        // Non-Query command for database action.
        private Boolean ModifyTable(OleDbConnection conn, string modCommand)
        {
            Boolean success = false;

            try
            {
                OleDbCommand nqcmd = conn.CreateCommand();
                nqcmd.CommandText = modCommand;
                nqcmd.ExecuteNonQuery();
                success = true;
            }
            catch (OleDbException odbe)
            {
                Console.WriteLine(”OleDbException: {0}”, odbe.Message);
            }
            finally
            {
                CloseDataConnection(conn);
            }
            return success;
        }
       
    }
}

 

This code serves it purpose well for what I needed it to do. Granted, you can do allot more research and figure out how to completely manipulate dBASE III files but this worked for me.

 

 

 

Published by Noble on 16 Nov 2007

Computer Maintenance Guide

I try and keep my computers running smoothly and trouble-free the best that I can. Below are some tips, tools, and resources that can make your machine happy, healthy, and trouble-free.

Every Day Maintenance:

  • Update your virus and spyware definitions: Viruses can spread very quickly so it is very important that you keep your anti-virus software up-to-date.
  • Do a backup: It is important to make backup’s of your work. Making backup’s are quick and easy and can save you allot of headaches in the future.
  • Reboot when programs crash: Whenever one of your programs crash it is important to just reboot your system and start over because when one program crashes it may cause others to become faulty as well.

Every Week Maintenance:

  • Perform a full virus and spyware scan: To make sure that your system stays clean from viruses and spyware it is important that you run a full virus scan and a full spyware scan every week,
  • Do a complete backup: If you just back up your changed files everyday then it would be a very wise decision to make a complete backup of your hard drive once a week.
  • Run Windows Update: In order to make sure that you have all the latest patches and fixes from Microsoft you need to run this update every week. It can be run from the start menu.

Every Month Maintenance:

  • Update your programs: Check your program’s vendor websites to download and install the latest updates to your programs in order to insure that your apps are more stable and secure.
  • Check for new drivers: By installing the latest drivers for your devices you can help speed up and stabilize your computer.

Every Year Maintenance:

  • Clean out your PC case:  Use a vacuum cleaner to carefully clear out the dust that collects in a case and can clog up the fans and make the electronic components run hot.
  • Spring-clean Windows and your programs: If your computer seems to run sluggish and bloated then it would be wise to make a full backup and the use the restore CD to return the system to its original state and then re-install all your programs and data.
  • Conduct a full diagnostic check: A hardware-diagnostic program can test your equipment and track down faulty devices and components before they fail completely.