Start New Discussion within our Software Development Community
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace PlayingWithSQLite1 {
    abstract class Database {
        
        #region Member Variables
        string PATH       = String.Format("{0}\\Database\\", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
        string FILENAME   = "test.s3db";
        #endregion

        public string File { 
            get { return string.Format("{0}\\{1}", PATH, FILENAME); }
        }

        public static void CreateDatabaseFile() {
            SQLiteConnection.CreateFile(File);
        }

    }
}

I just CANNOT figure out for the life of me what the error wants me to do.

Error 1 An object reference is required for the non-static field, method, or property 'PlayingWithSQLite1.Database.File.get' C:\Users\Chris\Documents\Visual Studio 2008\Projects\PlayingWithSQLite1\PlayingWithSQLite1\Database.cs 20 41 PlayingWithSQLite1

OK, I figured it out after all.. I hadn't considered that non-static variables/properties cannot be accessed without creating an instance of the class... so I just added static to the access modifiers.

This question has already been answered. Start a new discussion instead.