dimanche 11 octobre 2015

C# SQLiteDataAdapter Removing Backslashes

I am trying to read from an Sqlite database in to a DataTable using SQLiteDataAdapter. The data in the database contains backlashes in fractions being stored as VARCHAR data types. After filling the DataTable, the backslashes have been removed along with all trailing characters. I have confirmed the database does contain the backslashes.

This is my code:

DataTable dt = new DataTable();
using (SQLiteConnection m_dbConnection = new SQLiteConnection(connection))
{
    string sql = "Select Quantity From Recipes WHERE ID=@id;";
    using (SQLiteDataAdapter da = new SQLiteDataAdapter(sql, m_dbConnection))
    {
        da.AcceptChangesDuringUpdate = true;
        da.AcceptChangesDuringFill = true;
        da.SelectCommand.Parameters.Add(new SQLiteParameter("@id") { Value = ID });
        da.Fill(dt);
    }
}

The result in Quantity should return 1/2, but returns 1 instead. This is different than the problem most posts refer to where people are trying to insert backslashes. I couldn't find any information about reading backslashes.

Aucun commentaire:

Enregistrer un commentaire