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 8022389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:15:15+00:00 2026-06-04T22:15:15+00:00

I am trying to access a column of Blob’s in an SQLite DB which

  • 0

I am trying to access a column of Blob’s in an SQLite DB which will eventually be pointers to a record on a file or in memory. I’m trying to use the .GetBytes method in SQLite to get an array of bytes that will represent my data. I keep getting an InvalidCastException while using this method. Everything seems to be in place and the program compiles just fine, but during runtime this exception keeps getting thrown. I’ve looked around for answers and everything seems to agree with the code I have so I am at a loss here, and unfortunately I can’t find any good documentation for SQLite in C#. Code is as follows

  public byte[] Output()
    {
        byte[] temp = null;
        int col = Columns + 1;
        if(read.Read())
        {
            read.GetBytes(col, 0, temp, 0, 2048); //exception is thrown here
        }
        return temp;
    }

I’ve been able to read other columns in the DB that are ints and texts, but for some reason can’t seem to get the blobs right.

EDIT: new info, Here is the stack trace from the exception:

     StackTrace:
   at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
   at System.Data.SQLite.SQLiteDataReader.GetBytes(Int32 i, Int64 fieldOffset, Byte[] buffer, Int32 bufferoffset, Int32 length)
   at SQLiteSort.Sort.Output() in C:\Users\cjones\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Sort.cs:line 192
   at SQLiteSort.Sort.Main(String[] args) in C:\Users\cjones\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Sort.cs:line 72
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

InnerException:

The exception seems to be thrown by SQLiteDataReader.VerifyType(), this is looking at the column being used for a DbType.Binary type and throws an exception if the column is not a DbType.Binary, DbType.String, or DbType.Guid. I’ve checked the table over and over and it still shows the column type as a blob.

  • 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-04T22:15:16+00:00Added an answer on June 4, 2026 at 10:15 pm

    Well I finally fixed the problem by using parameter’s and setting my Blob to DbType.Binary. Not sure why this is so different from what I was doing before but everything is working as it should now.

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

Sidebar

Related Questions

I am trying to retrieve column descriptions for MS Access columns using C# (the
I'm trying to create a unique multi-column index on a table in Access. Several
I have been trying to access an xmlType column-table from my java application the
I'm trying to read the column names of a table Streets in an Access
I have an Access file developed using Access 2003, and am trying to work
I'm trying to access a phone number with starting an intent which opens the
I am trying to write java code to access a table 'customer' with columns
Trying to access a Servlet from a button on HTML page //Html Page FORM
Im trying to access the example/web folder (see below in the image) in a
When trying to access data-onload using $(#index).data(onload) I get back 'undefined' : <script type=text/html>

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.