简体   繁体   English

SQLite3.dll问题x64

[英]SQLite3.dll problems x64

I've solved my problem at SQLite sqlite3_column_origin_name function with a simply workaround but now I've an another big problem. 我已经通过简单的解决方法在SQLite sqlite3_column_origin_name函数中解决了我的问题,但是现在又遇到了另一个大问题。

I've a sqlwrapper with these imports: 我有这些导入的sqlwrapper:

    [DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_int")]
    static extern int sqlite3_column_int(IntPtr stmHandle, int iCol);

    [DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_text")]
    static extern string sqlite3_column_text(IntPtr stmHandle, int iCol);

    [DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_double")]
    static extern double sqlite3_column_double(IntPtr stmHandle, int iCol);

and this is my ExecuteQuery function: 这是我的ExecuteQuery函数:

    public DataTable ExecuteQuery(String query)
    {

        SQLiteWrapper.query = query;

        if (!_open)
            throw new SQLiteException("SQLite database is not open.");

        //prepare the statement
        IntPtr stmHandle = IntPtr.Zero;
        try
        {
            stmHandle = Prepare(query);
        }
        catch(Exception e)
        {
            Log.e(e.Message);
            return null;
        }


        // Prevensione sul out of memory
        if(stmHandle == IntPtr.Zero) 
        {
            return null;
        }

        //get the number of returned columns
        int columnCount = sqlite3_column_count(stmHandle);

        DataTable dTable = null;
        try
        {
            //create datatable and columns
            dTable = new DataTable();
            for (int i = 0; i < columnCount; i++)
            {
                try
                {
                    ArrayList selections = Utils.getQuerySelection(query);
                    foreach(String s in selections) 
                    {
                        dTable.Columns.Add(s);
                    }
                    //Workaround for sqlite3_column_origin_name

                    //dTable.Columns.Add("_id");
                   //dTable.Columns.Add(sqlite3_column_origin_name(stmHandle, i));
                }
                catch(Exception e) 
                {

                }
            }

            //populate datatable
            while (sqlite3_step(stmHandle) == SQLITE_ROW)
            {
                object[] row = new object[columnCount];
                for (int i = 0; i < columnCount; i++)
                {
                    switch (sqlite3_column_type(stmHandle, i))
                    {

                        case SQLITE_INTEGER:
                            // WORKS CORRECTLY!!!!
                            row[i] = sqlite3_column_int(stmHandle, i);
                            break;
                        case SQLITE_TEXT:
                            // ERROR!!!!!!!!!!!!!!!!!!!!!!
                            row[i] = sqlite3_column_text(stmHandle, i);
                            break;
                        case SQLITE_FLOAT:
                            row[i] = sqlite3_column_double(stmHandle, i);
                            break;
                    }
                }
                dTable.Rows.Add(row);
            }
        }
        catch(AccessViolationException ave)
        {
            Log.e("SqliteWrapper - AccessViolationException - " + ave.Message + ":" + query);
            return null;
        }

        // Se ci sono stati errori allora torna null e ritenta la query
        Boolean finalized = Finalize(stmHandle);
        if(!finalized) 
        {
            return null;
        }
        return dTable;
    }

When I invoke the sqlite3_column_text(...) my app crashes. 当我调用sqlite3_column_text(...)时,我的应用程序崩溃了。 I've explored functions within dll file and this entrypoint "sqlite3_column_text" exists. 我已经研究了dll文件中的函数,并且此入口点“ sqlite3_column_text”存在。

Can I solve my problem? 我可以解决我的问题吗?

EDIT: I download my sqlite3.dll file from http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.66.0/ 编辑:我从http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.66.0/下载我的sqlite3.dll文件

File is within /bin/x64 and I've renamed it into sqlite3.dll 文件位于/ bin / x64内,我已将其重命名为sqlite3.dll

EDIT 2: Clicking on more info I have: 编辑2:单击更多信息,我有:

File che contribuiscono alla descrizione del problema: 档案che contribuscoiscono all descrizione del问题:
C:\\Users\\Utente\\AppData\\Local\\Temp\\WERB927.tmp.WERInternalMetadata.xml C:\\Users\\Utente\\AppData\\Local\\Temp\\WERD59D.tmp.appcompat.txt C:\\ Users \\ Utente \\ AppData \\ Local \\ Temp \\ WERB927.tmp.WERInternalMetadata.xml C:\\ Users \\ Utente \\ AppData \\ Local \\ Temp \\ WERD59D.tmp.appcompat.txt
C:\\Users\\Utente\\AppData\\Local\\Temp\\WERD5BD.tmp.mdmp C:\\ Users \\ Utente \\ AppData \\ Local \\ Temp \\ WERD5BD.tmp.mdmp

Leggere l'informativa sulla privacy online: Leggere l'informativa sulla在线隐私:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0410 http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0410

Se l'informativa sulla privacy online non è disponibile, leggere quella offline: C:\\Windows\\system32\\it-IT\\erofflps.txt 在线隐私保护,离线和Leggere Quella离线:C:\\ Windows \\ system32 \\ it-IT \\ erofflps.txt

try following code 尝试以下代码

[DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_text")]
    static extern string sqlite3_column_text(IntPtr stmHandle, int iCol);

string → IntPtr 字符串→IntPtr

[DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_text")]
static extern IntPtr sqlite3_column_origin_name(IntPtr stmHandle, int iCol);

row[i] = Marshal.PtrToStringAnsi(sqlite3_column_text(stmHandle, i));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM