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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:11:01+00:00 2026-06-17T21:11:01+00:00

I am using the System.Data.SQLite ADO.Net Provider to interact with an SQLite DB. I

  • 0

I am using the System.Data.SQLite ADO.Net Provider to interact with an SQLite DB. I used the following syntax to create a new table:

CREATE TABLE [tb_Replace] ([Character] CHAR(1), [Substitute] CHAR(1))

I then tried to read the data using a simple select:

public static List<char> GetReplaceableCharacters(string connectionString)
{
    List<char> replaceableCharacters = new List<char>();
    SQLiteConnection sqlConnection = new SQLiteConnection(connectionString);
    sqlConnection.Open();
    using (SQLiteTransaction transaction = sqlConnection.BeginTransaction())
    {
        SQLiteCommand command = new SQLiteCommand(@"SELECT Character FROM tb_Replace", sqlConnection);
        SQLiteDataReader reader = command.ExecuteReader();
        while (reader.Read())
            replaceableCharacters.Add((char)reader["Character"]);
    }
    sqlConnection.Close();
    return replaceableCharacters;
}

However when I did that it threw an InvalidCastException. However, if I change the return type to aList<string> and cast reader["Character"] to a string it works. Does anyone know why this would be?

  • 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-17T21:11:02+00:00Added an answer on June 17, 2026 at 9:11 pm

    Just read http://www.sqlite.org/datatype3.html.

    Sqlite has five type affinities (types preferred by a column of a table) and five storage classes (possible actual value types). There is no CHARACTER type among either of them.

    Sqlite allows you to specify just about anything as a type for column creation. But it doesn’t enforce types for everything except INTEGER PRIMARY KEY columns. It recognizes a few substring of declared type names to determine column type affinity, so CHARACTER, CHARCOAL and CONTEXTUALIZABLE are all just a funny way of writing TEXT.

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

Sidebar

Related Questions

I am using the official System.Data.SQLite ADO.NET provider for my application, and I am
Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to
I downloaded System.Data.SQLite , and tried to compile the following sample code. using System;
I'm trying to access a SpatiaLite from C# using System.Data.SQLite provider. When I try
I'm asking about the .Net implementation - System.Data.SQLite. Are there guidelines to using it
I am using the System.data.sqlite.dll in my vb.net program. And for the life of
I want to read all rows in a table using system.data.sqlite. As I have
I am using System.Data.SQLite to store my program's data and settings (in a WPF
I am using SQLite from system.data.sqlite.org We need to access the database from many
I have a WPF Application using Fluent NHibernate 1.0 RTM and System.Data.SQLite 1.0.65 that

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.