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 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 ^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 ^)
{
}
}
}
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.