using System;
using System.Collections.Generic;
using System.Text;
using ConsoleApplication2.canopus5;
using d = System.Data;

namespace ConsoleApplication2
{
  class Program
  {
    static void Main(string[] args)
    {
      type t = null;
      SQLServer s = new SQLServer();      
      s.UseDefaultCredentials = true;
      SqlParameter[] parameters = new SqlParameter[2];
      parameters[0] = new SqlParameter();
      parameters[0].direction = ParameterDirection.Input;
      parameters[0].Value = 3;
      parameters[0].name = "P1";
      parameters[0].sqlDbType = sqlDbTypeEnum.Int;
      parameters[1] = new SqlParameter();
      parameters[1].direction = ParameterDirection.Input;
      parameters[1].Value = 4;
      parameters[1].name = "P2";
      parameters[1].sqlDbType = sqlDbTypeEnum.Int;

      object[] results = s.sqlbatch(
@"Select @P1 AS FIRST;
PRINT 'hello';
SELECT @P2 AS SECOND;", ref parameters);
      foreach (object result in results)
      {
        if (result is SqlRowCount)
        {
          Console.WriteLine("Row count {0}", (result as SqlRowCount).Count);
        }
        if (result is SqlMessage)
        {
          Console.WriteLine("Message {0}", (result as SqlMessage).Message);
        }
        if (result is d.DataSet)
        {
          Console.WriteLine("DataSet");
          (result as d.DataSet).WriteXml(Console.Out);
          Console.WriteLine();
        }
      }
    }
  }
}
