1234567891011121314151617181920212223242526272829303132333435
#include "stdafx.h" using namespace Platform; MyFunctions::MyFunctions(void) { } void MyFunctions::showMenu( String^ Query, String^ Message) { SqlCommand^ cmd = gcnew SqlCommand(Query, connection); try { connection->Open(); SqlDataReader^ reader = cmd->ExecuteReader(); while(reader->Read()) { String^ name = reader->GetString(reader->GetOrdinal("Name")); String^ price = reader->GetDouble(reader->GetOrdinal("Price")).ToString(); ListViewItem^ item = gcnew ListViewItem (name); item->SubItems->Add(price); listView1->Items->Add(item); } } catch(Exception^ e) { MessageBox::Show(Message); } finally { connection->Close(); } }