【问题标题】:SQLite Get columnsSQLite 获取列
【发布时间】:2018-01-26 01:14:42
【问题描述】:
public static List<string> GetColumns(SQLiteConnection connection, string tableName)
{
        List<string> a = null;
        try
        {
            string commandString = "PRAGMA table_info('" + tableName + "');";
            SQLiteCommand command = connection.CreateCommand(commandString, new object[0]);
            command.CommandText = commandString;
            a = command.ExecuteQuery<string>();
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }
        return a;
    }

我不知道如何从 executeQuery 中获取列。谁能帮帮我?

【问题讨论】:

    标签: c# sqlite


    【解决方案1】:

    您应该以读者身份执行查询:command.ExecuteReader()

    我想你的问题之前被问过。 here


    如果您使用sqlite-net-pcl,您只需致电connection.GetTableInfo(tableName)。它将为您提供包含其信息的列列表。

    【讨论】:

    • 这个包(SQLite PCL)不包含ExecuteReader方法
    • 如果您的意思是sqlite-net-pcl,要获取列名,您只需调用connection.GetTableInfo(tableName)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 2011-09-15
    相关资源
    最近更新 更多