Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:45:23+00:00 2026-06-16T09:45:23+00:00

I am trying to use SQLite to create an offline cache for a .NET

  • 0

I am trying to use SQLite to create an offline cache for a .NET application which normally requests data from a server. I’ve already got the database and table definition part working fine, and for the most part loading the data is working fine, too. I’m caching about 14,000 rows in my test table and the data is mostly correct. The problem is that I can’t seem to get the System.Data.SQLite wrapper to persist the byte[] data that comprises a SQL timestamp value.

Before anything else, I should note that I realize I could encode the timestamp as something else (string or numeric data, for instance), but I’d much rather use the native BLOB functionality instead, if possible. So let’s start there.

The table DDL looks like this, now:

CREATE TABLE Accounts
(
    AccountID Int NOT NULL,
    -- ...
    Timestamp BLOB
)

However I should note that I have also tried VARBINARY, VARBINARY(4000), BINARY, and GENERAL for Timestamp‘s column type, with no difference in the results.

At the time of insert, I generate a parameterized SQL command that looks like this (lots of fields removed for clarity):

INSERT INTO Accounts (AccountID, Timestamp)
SELECT @AccountID, @Timestamp
WHERE NOT EXISTS (SELECT 1 FROM Accounts WHERE AccountID = @AccountID)

The parameter @Timestamp is given a DbType of Binary and has the proper size, and all the other data in the inserted row looks fine. But for some reason, Timestamp is left null. Why might this be?

The value is verifiably a byte[8] with the expected contents. In fact, if I change the column type to have a string affinity and give it a DbType.String, the column will store “System.Byte[]”.

The fact that the column has a null value is certain, first by simply opening the database file using the SQLite Database Browser and looking, and second because setting a column in a second table using a (SELECT MAX(Timestamp) FROM Accounts) leaves the field null, which according to the docs happens if and only if every row’s Timestamp is null.

So what could I be missing?

** EDIT **

Note to all: this is SQLite, not SQL CE. Some responses seem to confuse the two.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:45:24+00:00Added an answer on June 16, 2026 at 9:45 am

    Well, this is really odd. I had a breakthrough when I realized that SQLite Database Browser was lying to me– it was truncating binary data at 0x0, which was the first byte of all my timestamp values, and reporting those fields as empty. I discovered this after trying inserting random byte data instead of the timestamps, at which point I saw the data come through in the GUI. Obviously it’s treating the data as null-terminated strings, and I didn’t know it was that naive at first.

    Now, I had been using the SQLite Database Browser as a proxy to debug the problem (which was DBNulls showing up when I tried to read the timestamp values out). But when I went back to see if I was still getting DBNull from the System.Data.SQLite wrapper, I discovered that the code, when run with just the original timestamp data in place, was no longer producing DBNulls. At some point the code had started working– I just hadn’t noticed because I foolishly relied on the GUI to show me the data.

    The odd part is, I tried retracing my steps, undoing things I’d done to try to figure out what specifically had fixed the problem. But now I can’t reproduce the original error, though it was absolutely consistent at first (the fact that I couldn’t get around it was what prompted me to use a GUI in the first place)! But I haven’t been checking each broken version into source control, so at this point I really don’t know what the issue was.

    Anyway, there’s at least one moral of the story, which is, don’t trust the GUI if you don’t know its capabilities for sure. Hard to say how long I’ve already had working code and just not known it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use an in-memory SQLite database to test my data layer which
I'm trying to use System.Data.Sqlite library, and I'm following the documentation about optimizing inserts
I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in
I'm trying to use sqlite in a 'data services' class like below. I keep
I use a SQLite database and Entity Framework (with .net framework 3.5). I'm trying
I am trying to use two different Core Data Models in a iPhone application,
I am trying to create a class to abstract my SQLite methods from my
I am barely learning MySQL (moving from SQLite). I am trying to create a
I'm trying to develop a simple app cross platform which use a SQLite db.
I'm trying to use org.sqlite.JDBC to create and update a sqlite database in ant.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.