SQLite Forum

GetDataTypeName broken?

GetDataTypeName broken?

(1) By anonymous on 2021-11-02 15:39:19 [link] [source]


in the past i used reader.GetDataTypeName on to get the type of pragma table_info PK.

Normally this would return the string "Integer", now it will return a empty string.

As workaround I now use reader.GetFieldType().Name.

Is this a known issue?

(2) By mistachkin on 2021-11-04 00:40:30 in reply to 1 [link] [source]

Could you please include some more specifics about the nature of the issue
you are seeing?

For example, a database schema and/or snippet of C# code that demonstrates
the issue.

(3) By anonymous on 2021-11-09 15:35:53 in reply to 2 [source]

First Create a database with:


then execute the following c# code:

using System; using System.Data.SQLite;

namespace SQLiteDataTypeTest { class Program { static void Main(string[] args) { SQLiteConnection Connection = new SQLiteConnection(@"Data Source=<THE_DATABASE>;"); Connection.Open();

        var sqlCommand = Connection.CreateCommand();
        var sqlQuery = "pragma table_info(test)";

        sqlCommand.CommandText = sqlQuery;

        var reader = sqlCommand.ExecuteReader();

        Console.WriteLine("Column name = " + reader.GetName(5)); //PK column
        Console.WriteLine("Datatype = " + reader.GetDataTypeName(5)); //PK column


This will result in the output: Column name = pk Datatype =

Datatype should here be integer since that's the column it's type.

(4.1) By mistachkin on 2021-11-09 16:40:13 edited from 4.0 in reply to 3 [link] [source]

Given what you appear to be trying to accomplish, I think the following query would work better:

SELECT * FROM test WHERE 1 = 0;

And then use:


EDIT: Alternatively, you can actually use (with your original example code):

reader.GetName(2); // "type"
reader.GetValue(2); // INTEGER

(5) By anonymous on 2021-11-09 22:14:58 in reply to 4.1 [link] [source]

I'm not looking for a alternative, this is used in a more complex code.

This was just a basic example to show it's broken. In 35 it still worked

(6) By mistachkin on 2021-11-10 02:13:45 in reply to 5 [link] [source]

Your example executes the SQL statement "PRAGMA table_info(test)".

However, the result rows returned by that SQL statement do not have
associated data type names, because those rows are not actually part
of a declared table.

(7) By anonymous on 2021-11-10 07:26:25 in reply to 6 [link] [source]

Yes, but in it still worked. Which means the versions are not backwards compatible.

Therefore is this broken or is this intended?

(8) By anonymous on 2021-11-10 09:25:26 in reply to 7 [link] [source] I mean.

(9) By mistachkin on 2021-11-10 21:20:34 in reply to 8 [link] [source]

I'm not sure how you were able to get a different result before; however,
everything appears to be working as designed.