1234567891011121314151617181920212223242526272829303132
String^ conString = "data source=.; database = Myproject; integrated security = SSPI"; SqlConnection^ connection = gcnew SqlConnection(conString); SqlCommand^ cmd = gcnew SqlCommand("SELECT [Name],[Price]FROM [MyProject].[dbo].[tblShisha]", connection); try { connection->Open(); SqlDataReader^ reader = cmd->ExecuteReader(); while(reader->Read()) { String^ name = reader->GetString("Name").ToString(); String^ price = reader->GetFloat("Price").ToString(); ListViewItem^ item = gcnew ListViewItem (name); item->SubItems->Add(price); listView1->Items->Add(item); } }catch(Exception^ e) { MessageBox::Show("Error importing Data from Shisha Table"); } finally { connection->Close(); }
float