{"id":1281,"date":"2015-01-07T13:42:02","date_gmt":"2015-01-07T13:42:02","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=1281"},"modified":"2022-02-17T06:24:03","modified_gmt":"2022-02-17T06:24:03","slug":"select-queries","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/databases\/sqlite\/queries\/select\/select-queries","title":{"rendered":"SELECT Queries"},"content":{"rendered":"<h4>\nSELECT Query Example<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tCommand1-&gt;CommandText = &quot;SELECT * FROM MyTable WHERE SomeColumnName &gt;= @StartValue AND SomeColumnName &lt;= @EndValue&quot;;\r\n\tCommand1-&gt;Parameters-&gt;AddWithValue(&quot;@StartValue&quot;, 14);\r\n\tCommand1-&gt;Parameters-&gt;AddWithValue(&quot;@EndValue&quot;, 28);\r\n\r\n\tSystem::Data::SQLite::SQLiteDataReader ^Reader1 = Command1-&gt;ExecuteReader();\r\n\t{\r\n\t\twhile (Reader1-&gt;Read())\r\n\t\t{\r\n\t\t\tMyVariable = Convert::ToString(Reader1[&quot;SomeColumnName1&quot;]);\r\n\t\t\tMyVariable2 = Convert::ToInt32(Reader1[&quot;SomeColumnName2&quot;]);\r\n\t\t}\r\n\t}\r\n\tReader1-&gt;Close();\r\n\t\/\/Bugfix to workaround sqlite &quot;database is locked&quot; issue when updating after a read\r\n\twhile (!Reader1-&gt;IsClosed)\r\n\t\tSystem::Threading::Thread::Sleep(1);\t\t\/\/mS\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<h4>\nReading DateTime&nbsp;In Select Statements<br \/>\n<\/h4>\n<p>\nYou need to specify you want the value returning in a DateTime format or you can just get the year portion returned!\n<\/p>\n<pre>\r\n<code>\r\n\tCommand1-&gt;CommandText = &quot;SELECT datetime(LogDateTime) as LogDateTime, SomeOtherColumnName FROM MyTable&quot;;\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT Query Example Command1-&gt;CommandText = &quot;SELECT * FROM MyTable WHERE SomeColumnName &gt;= @StartValue AND SomeColumnName &lt;= @EndValue&quot;; Command1-&gt;Parameters-&gt;AddWithValue(&quot;@StartValue&quot;, 14); Command1-&gt;Parameters-&gt;AddWithValue(&quot;@EndValue&quot;, 28); System::Data::SQLite::SQLiteDataReader ^Reader1 = Command1-&gt;ExecuteReader(); { while (Reader1-&gt;Read()) { MyVariable = Convert::ToString(Reader1[&quot;SomeColumnName1&quot;]); MyVariable2 = Convert::ToInt32(Reader1[&quot;SomeColumnName2&quot;]); } } Reader1-&gt;Close(); \/\/Bugfix to workaround sqlite &quot;database is locked&quot; issue when updating after a read while (!Reader1-&gt;IsClosed) System::Threading::Thread::Sleep(1); \/\/mS [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-1281","post","type-post","status-publish","format-standard","hentry","category-select"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/1281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=1281"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/1281\/revisions"}],"predecessor-version":[{"id":1476,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/1281\/revisions\/1476"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=1281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=1281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=1281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}