using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Common;
using Microsoft.SqlServer.Server;
namespace AdoMetaData
{
  class Program
  {
    static void Main(string[] args)
    {
      SqlConnectionStringBuilder cb = new SqlConnectionStringBuilder();
      cb.DataSource = ".";
      cb.IntegratedSecurity = true;
      cb.InitialCatalog = "Scratch";
      using (SqlConnection conn = new SqlConnection(cb.ToString()))
      {
        using(SqlCommand cmd = new SqlCommand(
          "Select  LDim::Fieldtest,dim.Inches, dim.test1, dim.test2 FROM DimT", conn))
        {
          conn.Open();
          SqlDataReader rdr = cmd.ExecuteReader();
          rdr.Read();
          Type t = rdr.GetProviderSpecificFieldType(0);
          DataTable dt = rdr.GetSchemaTable();
          dt.WriteXml(Console.Out);
          rdr.Close();
          cmd.CommandText ="SELECT LDim::Reverse('1 ft')";
          rdr = cmd.ExecuteReader();
          rdr.Read();
          dt = rdr.GetSchemaTable();
          dt.WriteXml(Console.Out);
          SqlMetaData md;
          

        }
      }
    }
  }
}
