Ejemplo n.º 1
0
 public static IEnumerable <SchemaTableRecord> GetResultSchema(this SqlConnectionString cs, string sql)
 {
     using (var connection = cs.OpenConnection())
     {
         using (var command = connection.CreateCommand(sql))
         {
             var table = command.GetSchemaTable();
             return(table.ReadProxies <SchemaTableRecord>());
         }
     }
 }
Ejemplo n.º 2
0
        private static DataTable GetDataTable(this SqlConnectionString cs, string sql, DataTable dst = null)
        {
            var dataTable = dst ?? new DataTable();

            using (var connection = cs.OpenConnection())
            {
                using (var command = connection.CreateCommand(sql))
                {
                    using (var adapter = new SqlDataAdapter(command))
                    {
                        adapter.Fill(dataTable);
                    }
                    return(dataTable);
                }
            }
        }