Jump to content

Database portability issue


Recommended Posts

Let me start by saying I am a complete Newb and I hope you are not offended by the simplicity of this question. That said, I created a simple sqlite database attached as "chatDB.db." I also created the code below to count the number of records in the database. It works fine on the machine that I used to write it. However, I cannot get it to work on other machines. I should also mention that I am running everything from a USB stick. I did change the location of the autoIt directory on Scite to match the changes to the path name when I switch machines. Two other symptoms: (i)code examples in the library for _sqlite_fetchdata and _sqlite_fetchname are not working on machine #2 either, and (ii) when I compile and run the script on the working machine it puts the executable an DB in the same location. Then it does not work. It basically won't work unless it is run from Scite on the original machine. I cannot figure out why. Does it have something to do with the way the application installs? Any help would be greatly appreciated.

SQL code:

#include <SQLite.au3>

#include <SQLite.dll.au3>

; this block of code will get the record count

dim $endOfRow[1]

Func getRecordCount()

Local $hQuery, $aRow, $aNames

_SQLite_Startup ()

_SQLite_Open (@ScriptDir&"\chatDB.db") ; open Database

dim $directory =@ScriptDir&"\chatDB.db"

;MsgBox("","directory", $directory) debug to make sure directory is correct

; the query to see how may records of nickName there are

_SQLite_Query(-1, "select count(nickName) from chatData",$hQuery)

_SQLite_FetchNames ($hQuery, $aNames)

While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; Read Out the next Row

_ArrayPush($endOfRow, $aRow[0])

WEnd

MsgBox("","this is the returned reord count:",$endOfRow[0])

Return $endOfRow[0]

EndFunc

; end block of code to get the record count

; test record count code

dim $recordCount = getRecordCount()

MsgBox("","this is the returned reord count:",$recordCount)

_SQLite_Close ()

_SQLite_Shutdown ()

chatDB.zip

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Let me start by saying I am a complete Newb and I hope you are not offended by the simplicity of this question. That said, I created a simple sqlite database attached as "chatDB.db." I also created the code below to count the number of records in the database. It works fine on the machine that I used to write it. However, I cannot get it to work on other machines. I should also mention that I am running everything from a USB stick. I did change the location of the autoIt directory on Scite to match the changes to the path name when I switch machines. Two other symptoms: (i)code examples in the library for _sqlite_fetchdata and _sqlite_fetchname are not working on machine #2 either, and (ii) when I compile and run the script on the working machine it puts the executable an DB in the same location. Then it does not work. It basically won't work unless it is run from Scite on the original machine. I cannot figure out why. Does it have something to do with the way the application installs? Any help would be greatly appreciated.

SQL code:

#include <SQLite.au3>

#include <SQLite.dll.au3>

; this block of code will get the record count

dim $endOfRow[1]

Func getRecordCount()

Local $hQuery, $aRow, $aNames

_SQLite_Startup ()

_SQLite_Open (@ScriptDir&"\chatDB.db") ; open Database

dim $directory =@ScriptDir&"\chatDB.db"

;MsgBox("","directory", $directory) debug to make sure directory is correct

; the query to see how may records of nickName there are

_SQLite_Query(-1, "select count(nickName) from chatData",$hQuery)

_SQLite_FetchNames ($hQuery, $aNames)

While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; Read Out the next Row

_ArrayPush($endOfRow, $aRow[0])

WEnd

MsgBox("","this is the returned reord count:",$endOfRow[0])

Return $endOfRow[0]

EndFunc

; end block of code to get the record count

; test record count code

dim $recordCount = getRecordCount()

MsgBox("","this is the returned reord count:",$recordCount)

_SQLite_Close ()

_SQLite_Shutdown ()

I would think that you need to put more error trapping in to find out where the probelm is.

For example, you have _SQLite_Startup () but you don't know if there was an error. So you should add some extra code to check @error, and then give a warning if needed.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I would think that you need to put more error trapping in to find out where the probelm is.

For example, you have _SQLite_Startup () but you don't know if there was an error. So you should add some extra code to check @error, and then give a warning if needed.

I am having trouble finding the error. Can you tell me if it works on your machine?

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Let me start by saying I am a complete Newb and I hope you are not offended by the simplicity of this question. That said, I created a simple sqlite database attached as "chatDB.db." I also created the code below to count the number of records in the database. It works fine on the machine that I used to write it. However, I cannot get it to work on other machines. I should also mention that I am running everything from a USB stick. I did change the location of the autoIt directory on Scite to match the changes to the path name when I switch machines. Two other symptoms: (i)code examples in the library for _sqlite_fetchdata and _sqlite_fetchname are not working on machine #2 either, and (ii) when I compile and run the script on the working machine it puts the executable an DB in the same location. Then it does not work. It basically won't work unless it is run from Scite on the original machine. I cannot figure out why. Does it have something to do with the way the application installs? Any help would be greatly appreciated.

SQL code:

#include <SQLite.au3>

#include <SQLite.dll.au3>

; this block of code will get the record count

dim $endOfRow[1]

Func getRecordCount()

Local $hQuery, $aRow, $aNames

_SQLite_Startup ()

_SQLite_Open (@ScriptDir&"\chatDB.db") ; open Database

dim $directory =@ScriptDir&"\chatDB.db"

;MsgBox("","directory", $directory) debug to make sure directory is correct

; the query to see how may records of nickName there are

_SQLite_Query(-1, "select count(nickName) from chatData",$hQuery)

_SQLite_FetchNames ($hQuery, $aNames)

While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; Read Out the next Row

_ArrayPush($endOfRow, $aRow[0])

WEnd

MsgBox("","this is the returned reord count:",$endOfRow[0])

Return $endOfRow[0]

EndFunc

; end block of code to get the record count

; test record count code

dim $recordCount = getRecordCount()

MsgBox("","this is the returned reord count:",$recordCount)

_SQLite_Close ()

_SQLite_Shutdown ()

I had something similar once and it was to do with the version of sqlite3.dll in system32. On my laptop I was using a version downloaded from the sqlite website which worked fine, when i tried to use it on another machine it was creating the sqlite3 dll file using #include <SQLite.dll.au3> eventually I figured it out and fileinstalled() the later version from the website rather than using the #include <SQLite.dll.au3> version.

Check the version of sqlite3.dll on your machine and then on the other machine where it doesn't work and see if they are the same, if they are the #include <SQLite.dll.au3> created versions then on my machine they don't have a version tab when you click on properties, the sqlite website version does have a version tab, so you might just have to check the file size as a comparison

Edit: Oh and the returned record count says 9 on my pc

Edited by ChrisL
Link to comment
Share on other sites

I had something similar once and it was to do with the version of sqlite3.dll in system32. On my laptop I was using a version downloaded from the sqlite website which worked fine, when i tried to use it on another machine it was creating the sqlite3 dll file using #include <SQLite.dll.au3> eventually I figured it out and fileinstalled() the later version from the website rather than using the #include <SQLite.dll.au3> version.

Check the version of sqlite3.dll on your machine and then on the other machine where it doesn't work and see if they are the same, if they are the #include <SQLite.dll.au3> created versions then on my machine they don't have a version tab when you click on properties, the sqlite website version does have a version tab, so you might just have to check the file size as a comparison

Edit: Oh and the returned record count says 9 on my pc

Thank you for trying that code and for the suggested issue. Nine is correct (and better than "" i.e. nothing, which is what I get on machine #2). I will look at the DLL as soon as I get to work. Thanks again.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...