SELECT Query Example

	Command1->CommandText = "SELECT * FROM MyTable WHERE SomeColumnName >= @StartValue AND SomeColumnName <= @EndValue";
	Command1->Parameters->AddWithValue("@StartValue", 14);
	Command1->Parameters->AddWithValue("@EndValue", 28);

	System::Data::SQLite::SQLiteDataReader ^Reader1 = Command1->ExecuteReader();
		while (Reader1->Read())
			MyVariable = Convert::ToString(Reader1["SomeColumnName1"]);
			MyVariable2 = Convert::ToInt32(Reader1["SomeColumnName2"]);
	//Bugfix to workaround sqlite "database is locked" issue when updating after a read
	while (!Reader1->IsClosed)
		System::Threading::Thread::Sleep(1);		//mS


Reading DateTime In Select Statements

You need to specify you want the value returning in a DateTime format or you can just get the year portion returned!

	Command1->CommandText = "SELECT datetime(LogDateTime) as LogDateTime, SomeOtherColumnName FROM MyTable";


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.


Your email address will not be published.