Skip to content

Instantly share code, notes, and snippets.

@afriza
Created May 13, 2011 04:01
Show Gist options
  • Save afriza/969954 to your computer and use it in GitHub Desktop.
Save afriza/969954 to your computer and use it in GitHub Desktop.
SQLite ADO.NET Provider with C++/CLI
// sqlite_cpp-cli.cpp
// Demonstrate SQLite ADO.NET Provider with C++/CLI
#include "stdafx.h"
#using "System.Data.SQLite.dll" // put this file in the project directory
using namespace System;
using namespace System::Data::SQLite;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello SQLite!");
SQLiteConnection conn;
conn.ConnectionString = "Data Source=mySQLite.db";
conn.Open();
SQLiteCommand sqlCmd(%conn);
sqlCmd.CommandText = "CREATE TABLE IF NOT EXISTS t (txt TEXT)";
sqlCmd.ExecuteNonQuery();
{
System::Console::WriteLine("Inserting 1,000,000 record..");
SQLiteTransaction %t = *conn.BeginTransaction();
sqlCmd.CommandText = "INSERT INTO t VALUES( ? )";
SQLiteParameter param1;
sqlCmd.Parameters->Add(%param1);
for (int i = 1; i <=1000000; i++)
{
param1.Value = i;
sqlCmd.ExecuteNonQuery();
}
t.Commit();
}
System::Console::WriteLine("Done..");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment