vendredi 29 mai 2015

ADO.Net reporting empty data type in SQLite

I am trying to dynamically get the schema of one of my views in SQLite using C#. I am using this code:

using (var connection = new SQLiteConnection(ConnectionString))
{
    connection.Open();
    using (DataTable columns = connection.GetSchema("Columns"))
    {
        foreach (DataRow row in columns.Rows)
        {
            string dataType = ((string) row["DATA_TYPE"]).Trim();
            // doing irrelevant other stuff here
        }
    }
}

Its working perfectly for all my tables and views except for one view. For some reason, the data type for the field called SaleAmount is coming up blank. There is nothing in the row["DATA_TYPE"] element.

Here is my view:

SELECT [Order Subtotals].Subtotal AS SaleAmount, 
              Orders.OrderID, 
           Customers.CompanyName, 
              Orders.ShippedDate
FROM Customers 
JOIN Orders ON Customers.CustomerID = Orders.CustomerID
JOIN [Order Subtotals] ON Orders.OrderID = [Order Subtotals].OrderID 
WHERE ([Order Subtotals].Subtotal >2500) 
AND (Orders.ShippedDate BETWEEN DATETIME('1997-01-01') And DATETIME('1997-12-31'))

I am using the standard System.Data.SQLite libraries. Anyone have any idea why this would come up blank? Like I said, it is happening only on this one field in this one view.

Aucun commentaire:

Enregistrer un commentaire