Skip to content

SqliteDataReader[<string>] is Case-Sensitive #24011

@BenKoth

Description

@BenKoth

The SqliteDataReader lookup when using a string is case-sensitive:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.data.sqlite.sqlitedatareader.item?view=msdata-sqlite-5.0.0#Microsoft_Data_Sqlite_SqliteDataReader_Item_System_String_

Why? This isn't true of any of the other data readers that I've used including the Microsoft SQL Data reader.
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqldatareader.item?view=dotnet-plat-ext-5.0#System_Data_SqlClient_SqlDataReader_Item_System_String_

To make matters worse, it is case-sensitive to the name of the column in the database, not what you select.

For example, if you have a table in your Sqlite database like the following:

CREATE TABLE test (testId INT)

The following code will error:

using (SqliteCommand command = new SqliteCommand("SELECT testID FROM test", conn))
{
  using (SqliteDataReader reader = command.ExecuteReader();
  {
    while (reader.read())
    {
      int testId = Convert.ToInt32(reader["testID"]);
    }
  } 
}

The lookup needs to use the same case as the table definition, not the query.
Microsoft.Data.Sqlite version: 5.0.2
Target framework: .Net Standard 2.0

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions