Database is locked error

We've found this can happen if executing an update after a read on a sqlite database file.  Tried all sorts of fixes, closing the connection in between, etc, etc, but nothing other than a long sleep delay would fix it.  From reading up it seems sqlite works in the background after returning from calls such as […]

Read More

Transmit lots of packets

If you don't have your socket set to non blocking (which means you have to deal with recv() wanting to block when you call it) then using the send() transmitfunction is no problem as it will block until the packet you are sending has gone out.  However if you have O_NONBLOCK non blocking turned on so […]

Read More

Set Colour

From RGB ListViewItem1->BackColor = Color::FromArgb(255, 0, 0); From Named Colour ListViewItem1->BackColor = System::Drawing::Color::Green;    

Read More

Convert Array To String

Convert an array of DateTime values to a string and back again //CONVERT ARRAY OF DATE TIME TO COMMA SEPARATED STRING array<DateTime> ^MyDateTimeArray; String ^MyString; MyString = ""; for (Count = 0; Count < MyDateTimeArray->Length; Count++) MyString += MyDateTimeArray[Count].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + ",";   //CONVERT COMMA SEPARATED STRING BACK TO ARRAY OF DATE TIME String ^sTemp; while (1) { […]

Read More

Colouring Combo Box Items

Set the ComboBox 'Draw Mode' to OwnerDrawFixed and then add this DrawItem event Colouring Text private: System::Void cmbMyComboBox_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e) { e->DrawBackground(); if (e->Index >= 0) { ComboBox ^ClickedComboBox = dynamic_cast<ComboBox^>(sender); String ^text = Convert::ToString(ClickedComboBox->Items[e->Index]); System::Drawing::Font ^Font1 = ClickedComboBox->Font; System::Drawing::Brush ^Brush1; if (e->Index == 0) Brush1 = Brushes::Red; else Brush1 = Brushes::Green; e->Graphics->DrawString(text, Font1, Brush1, […]

Read More

Delete Array Item

This is easier with a list as there's a built in function, but if you need to do it to an array: int IndexToRemove = 2; array<MyClassOrVariableName^> ^MyClassOrVariableName1_temp = gcnew array<MyClassOrVariableName^>(MyClassOrVariableName1->Length – 1); for (Count = 0; Count < MyClassOrVariableName1->Length; Count++) { if (Count < IndexToRemove) MyClassOrVariableName1_temp[Count] = MyClassOrVariableName1[Count]; else if (Count > IndexToRemove) MyClassOrVariableName1_temp[(Count […]

Read More

Sort Array

Sort Arrays Array::Sort Will sort an array in numerical order, and you can specify multiple arrays and they will bothbe sorted the same (i.e. an array of peoples names sorted according to another array of their ages), eg: Array::Sort(MyArrayWithSortKeys, MyOtherArray); //Sorts the entire Array using the default comparer. Sort An Array Of Custom Classes You […]

Read More

Rename Form

You need to deal with the renaming of the resource file or otherwise you get a MissingManifestResourceException.  TBC…

Read More

GROUP BY

IMPORTANT NOTE ABOUT GROUP BY The fields you get returned are not necessarily the fields from the exact same row in a collection of group by rows.  This is relevant when you for instance want to get the first occurrence of something within the group by, i.e. the row with the earliest datetime value (which wasn't […]

Read More