Good Resources

https://www.sqlite.org/lang_createtable.html

An Example


	bool DatabaseSqlite::InitialiseDatabase(void)
	{
		System::Data::SQLite::SQLiteConnection ^Connection1;
		String ^sTemp;

		try
		{

			//----- OPEN THE DATABASE CONNECTION -----
			Connection1 = gcnew 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 = gcnew System::Data::SQLite::SQLiteCommand(Connection1);

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

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

 

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.