An Example


		//*****************************************
		//*****************************************
		//********** INITIALISE DATABASE **********
		//*****************************************
		//*****************************************
		bool InitialiseDatabase()
		{
			System.Data.SQLite.SQLiteConnection Connection1 = null;
			String sTemp;

			try
			{

				//----- OPEN THE DATABASE CONNECTION -----
				Connection1 = new System.Data.SQLite.SQLiteConnection("data source=" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.CompanyName + "\\" + Application.ProductName + "\\mydatabasefile.db;Password=" + SQLITE_DATABASE_FILE_PASSWORD);
				Connection1.Open();

				System.Data.SQLite.SQLiteCommand Command1 = new System.Data.SQLite.SQLiteCommand(Connection1);

				//----- CREATE MY TABLE IF NECESSARY -----
				sTemp = @"CREATE TABLE IF NOT EXISTS tblMyTableName ( 
										Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 
									MyIntigerField INTEGER, 
                                    MyNumericField NUMERIC, 
                                    MyRealField REAL, 
                                    MyTextField TEXT 
									)";
				Command1.CommandText = sTemp;
				Command1.ExecuteNonQuery();

				return(true);
			}
			catch (Exception err)
			{
				MessageBox.Show("Error:\n" + err, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return(false);
			}
			finally
			{
				//----- CLOSE THE DATABASE CONNECTION -----
				try
				{
					if (Connection1 != null)
						Connection1.Close();
				}
				catch (Exception)
				{
				}
			}
		}

Unique Columns


CREATE TABLE bookmarks(
    users_id INTEGER,
    lessoninfo_id INTEGER,
    UNIQUE(users_id, lessoninfo_id)
);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *