// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;
using namespace System::Data::SqlClient;

int main(array<System::String ^> ^args)
{
    SqlConnection^ con = gcnew SqlConnection("Server=ARNEPC3\\SQLEXPRESS;Integrated Security=SSPI;Database=Test");
    con->Open();
    SqlCommand^ cmd = gcnew SqlCommand(L"SELECT f1,f2 FROM t1", con);
    SqlDataReader^ rdr = cmd->ExecuteReader();
    while(rdr->Read()) {
        int f1 = rdr->GetInt32(0);
        String^ f2 = rdr->GetString(1);
      Console::WriteLine(f1 + " " + f2);
    }
    con->Close();
    return 0;
}
