ADO.NET AND THE SQL SERVER MANAGED CLIENT

<pragma:references('system.data')>
<pragma:target('console')>

using System, System.Data, System.Data.SqlClient;

namespace Freya.Demos.SqlServer;

implementation

    method Main;
    // Click here for the compiled IL code!
    const
        ConnStr = 'database=Northwind;Integrated Security=true;server=(local);';
        CommandStr = 'select CustomerID, CompanyName from dbo.customers';
    begin
        try
            using connection := new SqlConnection(ConnStr),
                  command := new SqlCommand(CommandStr, connection)
            begin
                connection.Open;
                using reader := command.ExecuteReader
                    while reader.Read do
                        Console.WriteLine(String.Format('{0}: {1}',
                            reader['CustomerID'], reader['CompanyName']));
            end;
        except e: Exception do
            Console.WriteLine('An exception has been caught:');
            Console.WriteLine(e.Message);
        end;
    end;

end.