Development Visual C++ .NET

#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
ref struct MyEventHandler{
    static void CommandCompleted(IAsyncResult^ asyncResult){
        SqlCommand^ asyncCommand = dynamic_cast(asyncResult->AsyncState);
        
        if ( asyncCommand!= nullptr )
            SqlDataReader^ dataReader = asyncCommand->EndExecuteReader(asyncResult);
    }
};
void main()
{
    SqlConnectionStringBuilder^ connectionBuilder = gcnew SqlConnectionStringBuilder();
    connectionBuilder->AsynchronousProcessing = true;
    connectionBuilder->DataSource = "localhost";
    connectionBuilder->InitialCatalog = "myCatalog";
    connectionBuilder->UserID = "sa";
    connectionBuilder->Password = "";
    
    SqlConnection^ myConnection = gcnew SqlConnection(connectionBuilder->ToString());
    myConnection->Open();
    
    SqlCommand^ asyncCommand = myConnection->CreateCommand();
    asyncCommand->CommandText = "SELECT * FROM Music";
    
    AsyncCallback^ asyncCallback = gcnew AsyncCallback(MyEventHandler::CommandCompleted);
    
    IAsyncResult^ asyncResult = asyncCommand->BeginExecuteReader(asyncCallback, asyncCommand);
    
    asyncResult->AsyncWaitHandle->WaitOne();
}