#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::OleDb;
void main()
{
OleDbConnection^ myConnection = nullptr;
myConnection = gcnew OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Music.mdb");
myConnection->Open();
OleDbCommand^ myCommand = myConnection->CreateCommand();
myCommand->CommandText = "SELECT COUNT(*) FROM Music";
myCommand = gcnew OleDbCommand("SELECT COUNT(*) FROM Music",myConnection);
Object^ count = myCommand->ExecuteScalar();
Console::WriteLine("There are {0} songs in the Music table", count);
myCommand->CommandText ="DELETE FROM Music WHERE Genre='N'";
int RecordsAffected = myCommand->ExecuteNonQuery();
Console::WriteLine("{0} songs were deleted from the Music table",RecordsAffected);
myConnection->Close();
}
|