Sign in to follow this  
Followers 0
faustf

another question about sqlite

8 posts in this topic

hi guy i am in hell of sqlite (mysql is much better :D ) but i wanna use sqlite

i wanna read a db i have a table name : anagrafica and this structure inside

CREATE TABLE [anagrafica] (
[ana_id] integer NOT NULL PRIMARY KEY AUTOINCREMENT,
[Ana_Nome] varchar(25),
[Ana_Indirizzo] varchar(25),
[Ana_Citta] varchar(25),
[Ana_Provincia] varchar(25),
[Ana_Piva] varchar(25),
[Ana_CdF] varchar(25),
[Ana_telefono] varchar(25),
[Ana_mail] varchar(25),
[Ana_cell] varchar(25),
[Ana_fax] varchar(25),
[Ana_Nazione] varchar(25),
[Ana_Nome_Legale] varchar(25),
[Ana_Indirizzo_Legale] varchar(25),
[Ana_Citta_Legale] varchar(25),
[Ana_Provincia_Legale] varchar(25),
[Ana_Nazione_Legale] varchar(25),
[Ana_Ricordare] varchar(25),
[Ana_Mail_legale] varchar(25),
[Ana_Bank] varchar(25),
[Ana_Iban] varchar(25),
[Ana_Swift] varchar(25),
[Ana_Cell_Legale] varchar(25),
[Ana_Cap] varchar(25),
[Ana_Cap_Legale] varchar(25),
[Ana_Legale_e_Fisico] varchar(25),
[Ana_pagamento_assegnato] varchar(25)
)

i try to do this code

but of course dont go :D

Func _lettura_anagrafica()
  $Db=_SQLite_Open($percorso_Db); Open a permanent disk database
If @error Then
  MsgBox(16+262144, "SQLite Error", "Non posso Aprire il Database!")
  Exit -1
EndIf
_SQLite_Query($Db, "SELECT RowID,* FROM anagrafica;", $hQuery)
_SQLite_FetchData($hQuery, $aRow)
MsgBox(4 + 64, "Row: " & $aRow[1] ,"Continue Looping?")
_SQLite_QueryReset($hQuery)
_SQLite_QueryFinalize($hQuery)
_SQLite_Close()
_SQLite_Shutdown()
EndFunc

dont open db but i declare at top of script

Global $percorso_Db=@scriptdir & '\ditta.sqlite' ,$DataBase,$Db

Share this post


Link to post
Share on other sites



do a little correction but dont visualize array :P

Func _lettura_anagrafica()

_SQL_Startup()
  $Db=_SQLite_Open($percorso_Db); Open a permanent disk database
If @error Then
  MsgBox(16+262144, "SQLite Error", "Non posso Aprire il Database!")
  ;Exit -1
EndIf
_SQLite_Query($Db, "SELECT *,* FROM anagrafica;", $hQuery)
_SQLite_FetchData($hQuery, $aRow)
MsgBox(4 + 64, "Row: " & $aRow[0] ,"Continue Looping?")
_SQLite_QueryReset($hQuery)
_SQLite_QueryFinalize($hQuery)
_SQLite_Close()
_SQLite_Shutdown()
EndFunc

Share this post


Link to post
Share on other sites

Don't use these low-level functions.

Much simpler and efficient:

; perform this block once at startup
_SQLite_Startup()
Local $Db=_SQLite_Open($percorso_Db); Open a permanent disk database
If @error Then
  MsgBox(16+262144, "SQLite Error", "Non posso Aprire il Database!")
  ;Exit -1
EndIf

_lettura_anagrafica()
; there perform any operations your application needs

; perform this block before termination
_SQLite_Close($Db)
_SQLite_Shutdown()

Func _lettura_anagrafica()
    Local $aRow, $iRows, $iCols
    _SQLite_GetTable2d($Db, "SELECT * FROM anagrafica;", $aRow, $iRows, $iCols)
    _ArrayDisplay($aRow)
EndFunc

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

o thankz go perfectly but i dont wanna use external listview i wanna integrate how can do???

Share this post


Link to post
Share on other sites

faustf,

The listview (_arraydisplay) was just to show it working. "_sqlite_GetTable2D" returns a 2 dimensional array that you can use however you like...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

i do this but dont go

Local $aRow, $iRows, $iCols

_SQLite_GetTable2d($Db, "SELECT * FROM anagrafica;", $aRow, $iRows, $iCols)

; _ArrayDisplay($iRows)

msgbox(0,'',$iRows[1] )

Share this post


Link to post
Share on other sites

faustf,

$irows is a scalar variable, not an array. The result rows are in 2D array $arow.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

faustf,

Add code like this to display you resulting rows (not tested)

Local $aRow, $iRows, $iCols
_SQLite_GetTable2d($Db, "SELECT * FROM anagrafica;", $aRow, $iRows, $iCols)

ConsoleWrite('Number of rows returned = ' & $irow & @LF)
ConsoleWrite('Number of cols returned = ' & $icol & @LF)

local $str

for $1 = 0 to $iRows
    for $2 = 0 to $iCols
        ConsoleWrite($arow[$1][$2] & ' ')
    Next
    ConsoleWrite(@LF)
Next

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
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
Sign in to follow this  
Followers 0