0000: ef bb bf 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .../************
0010: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0020: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0030: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0a 20 2a 20 ************. *
0040: 41 44 4f 2e 4e 45 54 20 32 2e 30 20 44 61 74 61 ADO.NET 2.0 Data
0050: 20 50 72 6f 76 69 64 65 72 20 66 6f 72 20 53 51 Provider for SQ
0060: 4c 69 74 65 20 56 65 72 73 69 6f 6e 20 33 2e 58 Lite Version 3.X
0070: 0a 20 2a 20 57 72 69 74 74 65 6e 20 62 79 20 52 . * Written by R
0080: 6f 62 65 72 74 20 53 69 6d 70 73 6f 6e 20 28 72 obert Simpson (r
0090: 6f 62 65 72 74 40 62 6c 61 63 6b 63 61 73 74 6c obert@blackcastl
00a0: 65 73 6f 66 74 2e 63 6f 6d 29 0a 20 2a 20 0a 20 esoft.com). * .
00b0: 2a 20 52 65 6c 65 61 73 65 64 20 74 6f 20 74 68 * Released to th
00c0: 65 20 70 75 62 6c 69 63 20 64 6f 6d 61 69 6e 2c e public domain,
00d0: 20 75 73 65 20 61 74 20 79 6f 75 72 20 6f 77 6e use at your own
00e0: 20 72 69 73 6b 21 0a 20 2a 2a 2a 2a 2a 2a 2a 2a risk!. ********
00f0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0100: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0110: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0120: 2f 0a 0a 6e 61 6d 65 73 70 61 63 65 20 53 79 73 /..namespace Sys
0130: 74 65 6d 2e 44 61 74 61 2e 53 51 4c 69 74 65 0a tem.Data.SQLite.
0140: 7b 0a 20 20 75 73 69 6e 67 20 53 79 73 74 65 6d {. using System
0150: 3b 0a 20 20 75 73 69 6e 67 20 53 79 73 74 65 6d ;. using System
0160: 2e 44 61 74 61 3b 0a 20 20 75 73 69 6e 67 20 53 .Data;. using S
0170: 79 73 74 65 6d 2e 52 75 6e 74 69 6d 65 2e 49 6e ystem.Runtime.In
0180: 74 65 72 6f 70 53 65 72 76 69 63 65 73 3b 0a 20 teropServices;.
0190: 20 75 73 69 6e 67 20 53 79 73 74 65 6d 2e 43 6f using System.Co
01a0: 6c 6c 65 63 74 69 6f 6e 73 2e 47 65 6e 65 72 69 llections.Generi
01b0: 63 3b 0a 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 c;.. /// <summa
01c0: 72 79 3e 0a 20 20 2f 2f 2f 20 54 68 69 73 20 69 ry>. /// This i
01d0: 6e 74 65 72 6e 61 6c 20 63 6c 61 73 73 20 70 72 nternal class pr
01e0: 6f 76 69 64 65 73 20 74 68 65 20 66 6f 75 6e 64 ovides the found
01f0: 61 74 69 6f 6e 20 6f 66 20 53 51 4c 69 74 65 20 ation of SQLite
0200: 73 75 70 70 6f 72 74 2e 20 20 49 74 20 64 65 66 support. It def
0210: 69 6e 65 73 20 61 6c 6c 20 74 68 65 20 61 62 73 ines all the abs
0220: 74 72 61 63 74 20 6d 65 6d 62 65 72 73 20 6e 65 tract members ne
0230: 65 64 65 64 20 74 6f 20 69 6d 70 6c 65 6d 65 6e eded to implemen
0240: 74 0a 20 20 2f 2f 2f 20 61 20 53 51 4c 69 74 65 t. /// a SQLite
0250: 20 64 61 74 61 20 70 72 6f 76 69 64 65 72 2c 20 data provider,
0260: 61 6e 64 20 69 6e 68 65 72 69 74 73 20 66 72 6f and inherits fro
0270: 6d 20 53 51 4c 69 74 65 43 6f 6e 76 65 72 74 20 m SQLiteConvert
0280: 77 68 69 63 68 20 61 6c 6c 6f 77 73 20 66 6f 72 which allows for
0290: 20 73 69 6d 70 6c 65 20 74 72 61 6e 73 6c 61 74 simple translat
02a0: 69 6f 6e 73 20 6f 66 20 73 74 72 69 6e 67 20 74 ions of string t
02b0: 6f 20 61 6e 64 20 66 72 6f 6d 20 53 51 4c 69 74 o and from SQLit
02c0: 65 2e 0a 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 e.. /// </summa
02d0: 72 79 3e 0a 20 20 69 6e 74 65 72 6e 61 6c 20 61 ry>. internal a
02e0: 62 73 74 72 61 63 74 20 63 6c 61 73 73 20 53 51 bstract class SQ
02f0: 4c 69 74 65 42 61 73 65 20 3a 20 53 51 4c 69 74 LiteBase : SQLit
0300: 65 43 6f 6e 76 65 72 74 2c 20 49 44 69 73 70 6f eConvert, IDispo
0310: 73 61 62 6c 65 0a 20 20 7b 0a 20 20 20 20 69 6e sable. {. in
0320: 74 65 72 6e 61 6c 20 53 51 4c 69 74 65 42 61 73 ternal SQLiteBas
0330: 65 28 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d e(SQLiteDateForm
0340: 61 74 73 20 66 6d 74 29 0a 20 20 20 20 20 20 3a ats fmt). :
0350: 20 62 61 73 65 28 66 6d 74 29 20 7b 7d 0a 0a 20 base(fmt) {}..
0360: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
0370: 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 . /// Returns
0380: 20 61 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 a string repres
0390: 65 6e 74 69 6e 67 20 74 68 65 20 61 63 74 69 76 enting the activ
03a0: 65 20 76 65 72 73 69 6f 6e 20 6f 66 20 53 51 4c e version of SQL
03b0: 69 74 65 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 ite. /// </su
03c0: 6d 6d 61 72 79 3e 0a 20 20 20 20 69 6e 74 65 72 mmary>. inter
03d0: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 73 74 72 nal abstract str
03e0: 69 6e 67 20 56 65 72 73 69 6f 6e 20 7b 20 67 65 ing Version { ge
03f0: 74 3b 20 7d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 t; }. /// <su
0400: 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 52 mmary>. /// R
0410: 65 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 eturns the numbe
0420: 72 20 6f 66 20 63 68 61 6e 67 65 73 20 74 68 65 r of changes the
0430: 20 6c 61 73 74 20 65 78 65 63 75 74 69 6e 67 20 last executing
0440: 69 6e 73 65 72 74 2f 75 70 64 61 74 65 20 63 61 insert/update ca
0450: 75 73 65 64 2e 0a 20 20 20 20 2f 2f 2f 20 3c 2f used.. /// </
0460: 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 69 6e 74 summary>. int
0470: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 ernal abstract i
0480: 6e 74 20 20 20 20 43 68 61 6e 67 65 73 20 7b 20 nt Changes {
0490: 67 65 74 3b 20 7d 0a 20 20 20 20 2f 2f 2f 20 3c get; }. /// <
04a0: 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f summary>. ///
04b0: 20 4f 70 65 6e 73 20 61 20 64 61 74 61 62 61 73 Opens a databas
04c0: 65 2e 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d e.. /// </sum
04d0: 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 3c 72 mary>. /// <r
04e0: 65 6d 61 72 6b 73 3e 0a 20 20 20 20 2f 2f 2f 20 emarks>. ///
04f0: 49 6d 70 6c 65 6d 65 6e 74 65 72 73 20 73 68 6f Implementers sho
0500: 75 6c 64 20 63 61 6c 6c 20 53 51 4c 69 74 65 46 uld call SQLiteF
0510: 75 6e 63 74 69 6f 6e 2e 42 69 6e 64 46 75 6e 63 unction.BindFunc
0520: 74 69 6f 6e 73 28 29 20 61 6e 64 20 73 61 76 65 tions() and save
0530: 20 74 68 65 20 61 72 72 61 79 20 61 66 74 65 72 the array after
0540: 20 6f 70 65 6e 69 6e 67 20 61 20 63 6f 6e 6e 65 opening a conne
0550: 63 74 69 6f 6e 0a 20 20 20 20 2f 2f 2f 20 74 6f ction. /// to
0560: 20 62 69 6e 64 20 61 6c 6c 20 61 74 74 72 69 62 bind all attrib
0570: 75 74 65 64 20 75 73 65 72 2d 64 65 66 69 6e 65 uted user-define
0580: 64 20 66 75 6e 63 74 69 6f 6e 73 20 61 6e 64 20 d functions and
0590: 63 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e collating sequen
05a0: 63 65 73 20 74 6f 20 74 68 65 20 6e 65 77 20 63 ces to the new c
05b0: 6f 6e 6e 65 63 74 69 6f 6e 2e 0a 20 20 20 20 2f onnection.. /
05c0: 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0a 20 20 // </remarks>.
05d0: 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
05e0: 65 3d 22 73 74 72 46 69 6c 65 6e 61 6d 65 22 3e e="strFilename">
05f0: 54 68 65 20 66 69 6c 65 6e 61 6d 65 20 6f 66 20 The filename of
0600: 74 68 65 20 64 61 74 61 62 61 73 65 20 74 6f 20 the database to
0610: 6f 70 65 6e 2e 20 20 53 51 4c 69 74 65 20 61 75 open. SQLite au
0620: 74 6f 6d 61 74 69 63 61 6c 6c 79 20 63 72 65 61 tomatically crea
0630: 74 65 73 20 69 74 20 69 66 20 69 74 20 64 6f 65 tes it if it doe
0640: 73 6e 27 74 20 65 78 69 73 74 2e 3c 2f 70 61 72 sn't exist.</par
0650: 61 6d 3e 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c am>. internal
0660: 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 20 abstract void
0670: 20 4f 70 65 6e 28 73 74 72 69 6e 67 20 73 74 72 Open(string str
0680: 46 69 6c 65 6e 61 6d 65 29 3b 0a 20 20 20 20 2f Filename);. /
0690: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0a 20 20 20 // <summary>.
06a0: 20 2f 2f 2f 20 43 6c 6f 73 65 73 20 74 68 65 20 /// Closes the
06b0: 63 75 72 72 65 6e 74 6c 79 2d 6f 70 65 6e 20 64 currently-open d
06c0: 61 74 61 62 61 73 65 2e 0a 20 20 20 20 2f 2f 2f atabase.. ///
06d0: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 </summary>.
06e0: 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0a 20 20 /// <remarks>.
06f0: 20 20 2f 2f 2f 20 41 66 74 65 72 20 74 68 65 20 /// After the
0700: 64 61 74 61 62 61 73 65 20 68 61 73 20 62 65 65 database has bee
0710: 6e 20 63 6c 6f 73 65 64 20 69 6d 70 6c 65 6d 65 n closed impleme
0720: 74 65 72 73 20 73 68 6f 75 6c 64 20 63 61 6c 6c ters should call
0730: 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 2e SQLiteFunction.
0740: 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 28 UnbindFunctions(
0750: 29 20 74 6f 20 64 65 61 6c 6c 6f 63 61 74 65 20 ) to deallocate
0760: 61 6c 6c 20 69 6e 74 65 72 6f 70 20 61 6c 6c 6f all interop allo
0770: 63 61 74 65 64 0a 20 20 20 20 2f 2f 2f 20 6d 65 cated. /// me
0780: 6d 6f 72 79 20 61 73 73 6f 63 69 61 74 65 64 20 mory associated
0790: 77 69 74 68 20 74 68 65 20 75 73 65 72 2d 64 65 with the user-de
07a0: 66 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e 73 20 fined functions
07b0: 61 6e 64 20 63 6f 6c 6c 61 74 69 6e 67 20 73 65 and collating se
07c0: 71 75 65 6e 63 65 73 20 74 69 65 64 20 74 6f 20 quences tied to
07d0: 74 68 65 20 63 6c 6f 73 65 64 20 63 6f 6e 6e 65 the closed conne
07e0: 63 74 69 6f 6e 2e 0a 20 20 20 20 2f 2f 2f 20 3c ction.. /// <
07f0: 2f 72 65 6d 61 72 6b 73 3e 0a 20 20 20 20 69 6e /remarks>. in
0800: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
0810: 76 6f 69 64 20 20 20 43 6c 6f 73 65 28 29 3b 0a void Close();.
0820: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
0830: 3e 0a 20 20 20 20 2f 2f 2f 20 53 65 74 73 20 74 >. /// Sets t
0840: 68 65 20 62 75 73 79 20 74 69 6d 65 6f 75 74 20 he busy timeout
0850: 6f 6e 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f on the connectio
0860: 6e 2e 20 20 53 51 4c 69 74 65 43 6f 6d 6d 61 6e n. SQLiteComman
0870: 64 20 77 69 6c 6c 20 63 61 6c 6c 20 74 68 69 73 d will call this
0880: 20 62 65 66 6f 72 65 20 65 78 65 63 75 74 69 6e before executin
0890: 67 20 61 6e 79 20 63 6f 6d 6d 61 6e 64 2e 0a 20 g any command..
08a0: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
08b0: 3e 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d >. /// <param
08c0: 20 6e 61 6d 65 3d 22 6e 54 69 6d 65 6f 75 74 4d name="nTimeoutM
08d0: 53 22 3e 54 68 65 20 6e 75 6d 62 65 72 20 6f 66 S">The number of
08e0: 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 73 20 74 6f milliseconds to
08f0: 20 77 61 69 74 20 62 65 66 6f 72 65 20 72 65 74 wait before ret
0900: 75 72 6e 69 6e 67 20 53 51 4c 49 54 45 5f 42 55 urning SQLITE_BU
0910: 53 59 3c 2f 70 61 72 61 6d 3e 0a 20 20 20 20 69 SY</param>. i
0920: 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 nternal abstract
0930: 20 76 6f 69 64 20 20 20 53 65 74 54 69 6d 65 6f void SetTimeo
0940: 75 74 28 69 6e 74 20 6e 54 69 6d 65 6f 75 74 4d ut(int nTimeoutM
0950: 53 29 3b 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d S);. /// <sum
0960: 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 51 75 mary>. /// Qu
0970: 69 63 6b 20 65 78 65 63 75 74 65 20 6f 66 20 61 ick execute of a
0980: 20 53 51 4c 20 63 6f 6d 6d 61 6e 64 2e 20 20 54 SQL command. T
0990: 68 69 73 20 69 73 20 6f 6e 6c 79 20 65 78 65 63 his is only exec
09a0: 75 74 65 64 20 69 6e 74 65 72 6e 61 6c 6c 79 2c uted internally,
09b0: 20 75 73 75 61 6c 6c 79 20 62 79 20 53 51 4c 69 usually by SQLi
09c0: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 20 77 68 65 teConnection whe
09d0: 6e 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f 6e n the connection
09e0: 0a 20 20 20 20 2f 2f 2f 20 69 73 20 66 69 72 73 . /// is firs
09f0: 74 20 6f 70 65 6e 65 64 20 74 6f 20 73 65 74 20 t opened to set
0a00: 74 68 65 20 6e 65 63 65 73 73 61 72 79 20 73 74 the necessary st
0a10: 61 72 74 75 70 20 70 72 61 67 6d 61 73 2e 0a 20 artup pragmas..
0a20: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
0a30: 3e 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d >. /// <param
0a40: 20 6e 61 6d 65 3d 22 73 74 72 53 71 6c 22 3e 54 name="strSql">T
0a50: 68 65 20 53 51 4c 20 63 6f 6d 6d 61 6e 64 20 74 he SQL command t
0a60: 65 78 74 20 74 6f 20 65 78 65 63 75 74 65 3c 2f ext to execute</
0a70: 70 61 72 61 6d 3e 0a 20 20 20 20 69 6e 74 65 72 param>. inter
0a80: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 nal abstract voi
0a90: 64 20 20 20 45 78 65 63 75 74 65 28 73 74 72 69 d Execute(stri
0aa0: 6e 67 20 73 74 72 53 71 6c 29 3b 0a 20 20 20 20 ng strSql);.
0ab0: 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0a 20 20 /// <summary>.
0ac0: 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 74 68 /// Returns th
0ad0: 65 20 74 65 78 74 20 6f 66 20 74 68 65 20 6c 61 e text of the la
0ae0: 73 74 20 65 72 72 6f 72 20 69 73 73 75 65 64 20 st error issued
0af0: 62 79 20 53 51 4c 69 74 65 0a 20 20 20 20 2f 2f by SQLite. //
0b00: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0a 20 20 20 / </summary>.
0b10: 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 3c 2f /// <returns></
0b20: 72 65 74 75 72 6e 73 3e 0a 20 20 20 20 69 6e 74 returns>. int
0b30: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 73 ernal abstract s
0b40: 74 72 69 6e 67 20 53 51 4c 69 74 65 4c 61 73 74 tring SQLiteLast
0b50: 45 72 72 6f 72 28 29 3b 0a 0a 20 20 20 20 2f 2f Error();.. //
0b60: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 / <summary>.
0b70: 2f 2f 2f 20 50 72 65 70 61 72 65 73 20 61 20 53 /// Prepares a S
0b80: 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 66 6f 72 QL statement for
0b90: 20 65 78 65 63 75 74 69 6f 6e 2e 0a 20 20 20 20 execution..
0ba0: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0a 20 /// </summary>.
0bb0: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
0bc0: 6d 65 3d 22 73 74 72 53 71 6c 22 3e 54 68 65 20 me="strSql">The
0bd0: 53 51 4c 20 63 6f 6d 6d 61 6e 64 20 74 65 78 74 SQL command text
0be0: 20 74 6f 20 70 72 65 70 61 72 65 3c 2f 70 61 72 to prepare</par
0bf0: 61 6d 3e 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 am>. /// <par
0c00: 61 6d 20 6e 61 6d 65 3d 22 70 72 65 76 69 6f 75 am name="previou
0c10: 73 22 3e 54 68 65 20 70 72 65 76 69 6f 75 73 20 s">The previous
0c20: 73 74 61 74 65 6d 65 6e 74 20 69 6e 20 61 20 6d statement in a m
0c30: 75 6c 74 69 2d 73 74 61 74 65 6d 65 6e 74 20 63 ulti-statement c
0c40: 6f 6d 6d 61 6e 64 2c 20 6f 72 20 6e 75 6c 6c 20 ommand, or null
0c50: 69 66 20 6e 6f 20 70 72 65 76 69 6f 75 73 20 73 if no previous s
0c60: 74 61 74 65 6d 65 6e 74 20 65 78 69 73 74 73 3c tatement exists<
0c70: 2f 70 61 72 61 6d 3e 0a 20 20 20 20 2f 2f 2f 20 /param>. ///
0c80: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 72 <param name="str
0c90: 52 65 6d 61 69 6e 22 3e 54 68 65 20 72 65 6d 61 Remain">The rema
0ca0: 69 6e 64 65 72 20 6f 66 20 74 68 65 20 73 74 61 inder of the sta
0cb0: 74 65 6d 65 6e 74 20 74 68 61 74 20 77 61 73 20 tement that was
0cc0: 6e 6f 74 20 70 72 6f 63 65 73 73 65 64 2e 20 20 not processed.
0cd0: 45 61 63 68 20 63 61 6c 6c 20 74 6f 20 70 72 65 Each call to pre
0ce0: 70 61 72 65 20 70 61 72 73 65 73 20 74 68 65 0a pare parses the.
0cf0: 20 20 20 20 2f 2f 2f 20 53 51 4c 20 75 70 20 74 /// SQL up t
0d00: 6f 20 74 6f 20 65 69 74 68 65 72 20 74 68 65 20 o to either the
0d10: 65 6e 64 20 6f 66 20 74 68 65 20 74 65 78 74 20 end of the text
0d20: 6f 72 20 74 6f 20 74 68 65 20 66 69 72 73 74 20 or to the first
0d30: 73 65 6d 69 2d 63 6f 6c 6f 6e 20 64 65 6c 69 6d semi-colon delim
0d40: 69 74 65 72 2e 20 20 54 68 65 20 72 65 6d 61 69 iter. The remai
0d50: 6e 69 6e 67 20 74 65 78 74 20 69 73 20 72 65 74 ning text is ret
0d60: 75 72 6e 65 64 0a 20 20 20 20 2f 2f 2f 20 68 65 urned. /// he
0d70: 72 65 20 66 6f 72 20 61 20 73 75 62 73 65 71 75 re for a subsequ
0d80: 65 6e 74 20 63 61 6c 6c 20 74 6f 20 50 72 65 70 ent call to Prep
0d90: 61 72 65 28 29 20 75 6e 74 69 6c 20 61 6c 6c 20 are() until all
0da0: 74 68 65 20 74 65 78 74 20 68 61 73 20 62 65 65 the text has bee
0db0: 6e 20 70 72 6f 63 65 73 73 65 64 2e 3c 2f 70 61 n processed.</pa
0dc0: 72 61 6d 3e 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 ram>. /// <re
0dd0: 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 20 61 6e turns>Returns an
0de0: 20 69 6e 69 74 69 61 6c 69 7a 65 64 20 53 51 4c initialized SQL
0df0: 69 74 65 53 74 61 74 65 6d 65 6e 74 2e 3c 2f 72 iteStatement.</r
0e00: 65 74 75 72 6e 73 3e 0a 20 20 20 20 69 6e 74 65 eturns>. inte
0e10: 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 53 51 rnal abstract SQ
0e20: 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 50 72 LiteStatement Pr
0e30: 65 70 61 72 65 28 73 74 72 69 6e 67 20 73 74 72 epare(string str
0e40: 53 71 6c 2c 20 53 51 4c 69 74 65 53 74 61 74 65 Sql, SQLiteState
0e50: 6d 65 6e 74 20 70 72 65 76 69 6f 75 73 2c 20 6f ment previous, o
0e60: 75 74 20 73 74 72 69 6e 67 20 73 74 72 52 65 6d ut string strRem
0e70: 61 69 6e 29 3b 0a 20 20 20 20 2f 2f 2f 20 3c 73 ain);. /// <s
0e80: 75 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 ummary>. ///
0e90: 53 74 65 70 73 20 74 68 72 6f 75 67 68 20 61 20 Steps through a
0ea0: 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
0eb0: 6e 74 2e 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 nt.. /// </su
0ec0: 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 3c mmary>. /// <
0ed0: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 6d 74 param name="stmt
0ee0: 22 3e 54 68 65 20 53 51 4c 69 74 65 53 74 61 74 ">The SQLiteStat
0ef0: 65 6d 65 6e 74 20 74 6f 20 73 74 65 70 20 74 68 ement to step th
0f00: 72 6f 75 67 68 3c 2f 70 61 72 61 6d 3e 0a 20 20 rough</param>.
0f10: 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 54 /// <returns>T
0f20: 72 75 65 20 69 66 20 61 20 72 6f 77 20 77 61 73 rue if a row was
0f30: 20 72 65 74 75 72 6e 65 64 2c 20 46 61 6c 73 65 returned, False
0f40: 20 69 66 20 6e 6f 74 2e 3c 2f 72 65 74 75 72 6e if not.</return
0f50: 73 3e 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 s>. internal
0f60: 61 62 73 74 72 61 63 74 20 62 6f 6f 6c 20 53 74 abstract bool St
0f70: 65 70 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 ep(SQLiteStateme
0f80: 6e 74 20 73 74 6d 74 29 3b 0a 20 20 20 20 2f 2f nt stmt);. //
0f90: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 / <summary>.
0fa0: 2f 2f 2f 20 46 69 6e 61 6c 69 7a 65 73 20 61 20 /// Finalizes a
0fb0: 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
0fc0: 6e 74 2e 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 nt.. /// </su
0fd0: 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 3c mmary>. /// <
0fe0: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 6d 74 param name="stmt
0ff0: 22 3e 54 68 65 20 73 74 61 74 65 6d 65 6e 74 20 ">The statement
1000: 74 6f 20 66 69 6e 61 6c 69 7a 65 3c 2f 70 61 72 to finalize</par
1010: 61 6d 3e 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c am>. internal
1020: 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 46 abstract void F
1030: 69 6e 61 6c 69 7a 65 53 74 61 74 65 6d 65 6e 74 inalizeStatement
1040: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
1050: 20 73 74 6d 74 29 3b 0a 20 20 20 20 2f 2f 2f 20 stmt);. ///
1060: 3c 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f <summary>. //
1070: 2f 20 52 65 73 65 74 73 20 61 20 70 72 65 70 61 / Resets a prepa
1080: 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 73 6f red statement so
1090: 20 69 74 20 63 61 6e 20 62 65 20 65 78 65 63 75 it can be execu
10a0: 74 65 64 20 61 67 61 69 6e 2e 20 20 49 66 20 74 ted again. If t
10b0: 68 65 20 65 72 72 6f 72 20 72 65 74 75 72 6e 65 he error returne
10c0: 64 20 69 73 20 53 51 4c 49 54 45 5f 53 43 48 45 d is SQLITE_SCHE
10d0: 4d 41 2c 20 0a 20 20 20 20 2f 2f 2f 20 74 72 61 MA, . /// tra
10e0: 6e 73 70 61 72 65 6e 74 6c 79 20 61 74 74 65 6d nsparently attem
10f0: 70 74 20 74 6f 20 72 65 62 75 69 6c 64 20 74 68 pt to rebuild th
1100: 65 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 e SQL statement
1110: 61 6e 64 20 74 68 72 6f 77 20 61 6e 20 65 72 72 and throw an err
1120: 6f 72 20 69 66 20 74 68 61 74 20 77 61 73 20 6e or if that was n
1130: 6f 74 20 70 6f 73 73 69 62 6c 65 2e 0a 20 20 20 ot possible..
1140: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0a /// </summary>.
1150: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
1160: 61 6d 65 3d 22 73 74 6d 74 22 3e 54 68 65 20 73 ame="stmt">The s
1170: 74 61 74 65 6d 65 6e 74 20 74 6f 20 72 65 73 65 tatement to rese
1180: 74 3c 2f 70 61 72 61 6d 3e 0a 20 20 20 20 2f 2f t</param>. //
1190: 2f 20 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 / <returns>Retur
11a0: 6e 73 20 2d 31 20 69 66 20 74 68 65 20 73 63 68 ns -1 if the sch
11b0: 65 6d 61 20 63 68 61 6e 67 65 64 20 77 68 69 6c ema changed whil
11c0: 65 20 72 65 73 65 74 74 69 6e 67 2c 20 30 20 69 e resetting, 0 i
11d0: 66 20 74 68 65 20 72 65 73 65 74 20 77 61 73 20 f the reset was
11e0: 73 75 63 65 73 73 66 75 6c 20 6f 72 20 36 20 28 sucessful or 6 (
11f0: 53 51 4c 49 54 45 5f 4c 4f 43 4b 45 44 29 20 69 SQLITE_LOCKED) i
1200: 66 20 74 68 65 20 72 65 73 65 74 20 66 61 69 6c f the reset fail
1210: 65 64 20 64 75 65 20 74 6f 20 61 20 6c 6f 63 6b ed due to a lock
1220: 3c 2f 72 65 74 75 72 6e 73 3e 0a 20 20 20 20 69 </returns>. i
1230: 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 nternal abstract
1240: 20 69 6e 74 20 52 65 73 65 74 28 53 51 4c 69 74 int Reset(SQLit
1250: 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 29 eStatement stmt)
1260: 3b 0a 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ;.. internal
1270: 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 43 61 abstract void Ca
1280: 6e 63 65 6c 28 29 3b 0a 0a 20 20 20 20 69 6e 74 ncel();.. int
1290: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 76 ernal abstract v
12a0: 6f 69 64 20 42 69 6e 64 5f 44 6f 75 62 6c 65 28 oid Bind_Double(
12b0: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
12c0: 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c stmt, int index,
12d0: 20 64 6f 75 62 6c 65 20 76 61 6c 75 65 29 3b 0a double value);.
12e0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
12f0: 74 72 61 63 74 20 76 6f 69 64 20 42 69 6e 64 5f tract void Bind_
1300: 49 6e 74 33 32 28 53 51 4c 69 74 65 53 74 61 74 Int32(SQLiteStat
1310: 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 ement stmt, int
1320: 69 6e 64 65 78 2c 20 49 6e 74 33 32 20 76 61 6c index, Int32 val
1330: 75 65 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 ue);. interna
1340: 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 l abstract void
1350: 42 69 6e 64 5f 49 6e 74 36 34 28 53 51 4c 69 74 Bind_Int64(SQLit
1360: 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c eStatement stmt,
1370: 20 69 6e 74 20 69 6e 64 65 78 2c 20 49 6e 74 36 int index, Int6
1380: 34 20 76 61 6c 75 65 29 3b 0a 20 20 20 20 69 6e 4 value);. in
1390: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
13a0: 76 6f 69 64 20 42 69 6e 64 5f 54 65 78 74 28 53 void Bind_Text(S
13b0: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
13c0: 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 tmt, int index,
13d0: 73 74 72 69 6e 67 20 76 61 6c 75 65 29 3b 0a 20 string value);.
13e0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 internal abst
13f0: 72 61 63 74 20 76 6f 69 64 20 42 69 6e 64 5f 42 ract void Bind_B
1400: 6c 6f 62 28 53 51 4c 69 74 65 53 74 61 74 65 6d lob(SQLiteStatem
1410: 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
1420: 64 65 78 2c 20 62 79 74 65 5b 5d 20 62 6c 6f 62 dex, byte[] blob
1430: 44 61 74 61 29 3b 0a 20 20 20 20 69 6e 74 65 72 Data);. inter
1440: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 nal abstract voi
1450: 64 20 42 69 6e 64 5f 44 61 74 65 54 69 6d 65 28 d Bind_DateTime(
1460: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
1470: 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c stmt, int index,
1480: 20 44 61 74 65 54 69 6d 65 20 64 74 29 3b 0a 20 DateTime dt);.
1490: 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 internal abst
14a0: 72 61 63 74 20 76 6f 69 64 20 42 69 6e 64 5f 4e ract void Bind_N
14b0: 75 6c 6c 28 53 51 4c 69 74 65 53 74 61 74 65 6d ull(SQLiteStatem
14c0: 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
14d0: 64 65 78 29 3b 0a 0a 20 20 20 20 69 6e 74 65 72 dex);.. inter
14e0: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 6e 74 nal abstract int
14f0: 20 20 20 20 42 69 6e 64 5f 50 61 72 61 6d 43 6f Bind_ParamCo
1500: 75 6e 74 28 53 51 4c 69 74 65 53 74 61 74 65 6d unt(SQLiteStatem
1510: 65 6e 74 20 73 74 6d 74 29 3b 0a 20 20 20 20 69 ent stmt);. i
1520: 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 nternal abstract
1530: 20 73 74 72 69 6e 67 20 42 69 6e 64 5f 50 61 72 string Bind_Par
1540: 61 6d 4e 61 6d 65 28 53 51 4c 69 74 65 53 74 61 amName(SQLiteSta
1550: 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 tement stmt, int
1560: 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 69 6e 74 index);. int
1570: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 ernal abstract i
1580: 6e 74 20 20 20 20 42 69 6e 64 5f 50 61 72 61 6d nt Bind_Param
1590: 49 6e 64 65 78 28 53 51 4c 69 74 65 53 74 61 74 Index(SQLiteStat
15a0: 65 6d 65 6e 74 20 73 74 6d 74 2c 20 73 74 72 69 ement stmt, stri
15b0: 6e 67 20 70 61 72 61 6d 4e 61 6d 65 29 3b 0a 0a ng paramName);..
15c0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
15d0: 74 72 61 63 74 20 69 6e 74 20 20 20 20 43 6f 6c tract int Col
15e0: 75 6d 6e 43 6f 75 6e 74 28 53 51 4c 69 74 65 53 umnCount(SQLiteS
15f0: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 29 3b 0a tatement stmt);.
1600: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
1610: 74 72 61 63 74 20 73 74 72 69 6e 67 20 43 6f 6c tract string Col
1620: 75 6d 6e 4e 61 6d 65 28 53 51 4c 69 74 65 53 74 umnName(SQLiteSt
1630: 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e atement stmt, in
1640: 74 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 69 6e t index);. in
1650: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
1660: 73 74 72 69 6e 67 20 43 6f 6c 75 6d 6e 54 79 70 string ColumnTyp
1670: 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e e(SQLiteStatemen
1680: 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
1690: 78 2c 20 6f 75 74 20 54 79 70 65 41 66 66 69 6e x, out TypeAffin
16a0: 69 74 79 20 6e 41 66 66 69 6e 69 74 79 29 3b 0a ity nAffinity);.
16b0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
16c0: 74 72 61 63 74 20 69 6e 74 20 20 20 20 43 6f 6c tract int Col
16d0: 75 6d 6e 49 6e 64 65 78 28 53 51 4c 69 74 65 53 umnIndex(SQLiteS
16e0: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 73 tatement stmt, s
16f0: 74 72 69 6e 67 20 63 6f 6c 75 6d 6e 4e 61 6d 65 tring columnName
1700: 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 );. internal
1710: 61 62 73 74 72 61 63 74 20 73 74 72 69 6e 67 20 abstract string
1720: 43 6f 6c 75 6d 6e 4f 72 69 67 69 6e 61 6c 4e 61 ColumnOriginalNa
1730: 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 me(SQLiteStateme
1740: 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
1750: 65 78 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 ex);. interna
1760: 6c 20 61 62 73 74 72 61 63 74 20 73 74 72 69 6e l abstract strin
1770: 67 20 43 6f 6c 75 6d 6e 44 61 74 61 62 61 73 65 g ColumnDatabase
1780: 4e 61 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 Name(SQLiteState
1790: 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 ment stmt, int i
17a0: 6e 64 65 78 29 3b 0a 20 20 20 20 69 6e 74 65 72 ndex);. inter
17b0: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 73 74 72 nal abstract str
17c0: 69 6e 67 20 43 6f 6c 75 6d 6e 54 61 62 6c 65 4e ing ColumnTableN
17d0: 61 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d ame(SQLiteStatem
17e0: 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
17f0: 64 65 78 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e dex);. intern
1800: 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 al abstract void
1810: 20 43 6f 6c 75 6d 6e 4d 65 74 61 44 61 74 61 28 ColumnMetaData(
1820: 73 74 72 69 6e 67 20 64 61 74 61 42 61 73 65 2c string dataBase,
1830: 20 73 74 72 69 6e 67 20 74 61 62 6c 65 2c 20 73 string table, s
1840: 74 72 69 6e 67 20 63 6f 6c 75 6d 6e 2c 20 6f 75 tring column, ou
1850: 74 20 73 74 72 69 6e 67 20 64 61 74 61 54 79 70 t string dataTyp
1860: 65 2c 20 6f 75 74 20 73 74 72 69 6e 67 20 63 6f e, out string co
1870: 6c 6c 61 74 65 53 65 71 75 65 6e 63 65 2c 20 6f llateSequence, o
1880: 75 74 20 62 6f 6f 6c 20 6e 6f 74 4e 75 6c 6c 2c ut bool notNull,
1890: 20 6f 75 74 20 62 6f 6f 6c 20 70 72 69 6d 61 72 out bool primar
18a0: 79 4b 65 79 2c 20 6f 75 74 20 62 6f 6f 6c 20 61 yKey, out bool a
18b0: 75 74 6f 49 6e 63 72 65 6d 65 6e 74 29 3b 0a 0a utoIncrement);..
18c0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
18d0: 74 72 61 63 74 20 64 6f 75 62 6c 65 20 20 20 47 tract double G
18e0: 65 74 44 6f 75 62 6c 65 28 53 51 4c 69 74 65 53 etDouble(SQLiteS
18f0: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 tatement stmt, i
1900: 6e 74 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 69 nt index);. i
1910: 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 nternal abstract
1920: 20 49 6e 74 33 32 20 20 20 20 47 65 74 49 6e 74 Int32 GetInt
1930: 33 32 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 32(SQLiteStateme
1940: 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
1950: 65 78 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 ex);. interna
1960: 6c 20 61 62 73 74 72 61 63 74 20 49 6e 74 36 34 l abstract Int64
1970: 20 20 20 20 47 65 74 49 6e 74 36 34 28 53 51 4c GetInt64(SQL
1980: 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
1990: 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 3b 0a 20 t, int index);.
19a0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 internal abst
19b0: 72 61 63 74 20 73 74 72 69 6e 67 20 20 20 47 65 ract string Ge
19c0: 74 54 65 78 74 28 53 51 4c 69 74 65 53 74 61 74 tText(SQLiteStat
19d0: 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 ement stmt, int
19e0: 69 6e 64 65 78 29 3b 0a 20 20 20 20 69 6e 74 65 index);. inte
19f0: 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 6c 6f rnal abstract lo
1a00: 6e 67 20 20 20 20 20 47 65 74 42 79 74 65 73 28 ng GetBytes(
1a10: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
1a20: 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c stmt, int index,
1a30: 20 69 6e 74 20 6e 44 61 74 61 6f 66 66 73 65 74 int nDataoffset
1a40: 2c 20 62 79 74 65 5b 5d 20 62 44 65 73 74 2c 20 , byte[] bDest,
1a50: 69 6e 74 20 6e 53 74 61 72 74 2c 20 69 6e 74 20 int nStart, int
1a60: 6e 4c 65 6e 67 74 68 29 3b 0a 20 20 20 20 69 6e nLength);. in
1a70: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
1a80: 6c 6f 6e 67 20 20 20 20 20 47 65 74 43 68 61 72 long GetChar
1a90: 73 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e s(SQLiteStatemen
1aa0: 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
1ab0: 78 2c 20 69 6e 74 20 6e 44 61 74 61 6f 66 66 73 x, int nDataoffs
1ac0: 65 74 2c 20 63 68 61 72 5b 5d 20 62 44 65 73 74 et, char[] bDest
1ad0: 2c 20 69 6e 74 20 6e 53 74 61 72 74 2c 20 69 6e , int nStart, in
1ae0: 74 20 6e 4c 65 6e 67 74 68 29 3b 0a 20 20 20 20 t nLength);.
1af0: 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 internal abstrac
1b00: 74 20 44 61 74 65 54 69 6d 65 20 47 65 74 44 61 t DateTime GetDa
1b10: 74 65 54 69 6d 65 28 53 51 4c 69 74 65 53 74 61 teTime(SQLiteSta
1b20: 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 tement stmt, int
1b30: 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 69 6e 74 index);. int
1b40: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 62 ernal abstract b
1b50: 6f 6f 6c 20 20 20 20 20 49 73 4e 75 6c 6c 28 53 ool IsNull(S
1b60: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
1b70: 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 3b tmt, int index);
1b80: 0a 20 20 20 20 0a 20 20 20 20 2f 2f 2f 20 3c 73 . . /// <s
1b90: 75 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f 2f 20 ummary>. ///
1ba0: 48 65 6c 70 65 72 20 66 75 6e 63 74 69 6f 6e 20 Helper function
1bb0: 74 6f 20 72 65 74 72 69 65 76 65 20 61 20 63 6f to retrieve a co
1bc0: 6c 75 6d 6e 20 6f 66 20 64 61 74 61 20 66 72 6f lumn of data fro
1bd0: 6d 20 61 6e 20 61 63 74 69 76 65 20 73 74 61 74 m an active stat
1be0: 65 6d 65 6e 74 2e 0a 20 20 20 20 2f 2f 2f 20 3c ement.. /// <
1bf0: 2f 73 75 6d 6d 61 72 79 3e 0a 20 20 20 20 2f 2f /summary>. //
1c00: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 / <param name="s
1c10: 74 6d 74 22 3e 54 68 65 20 73 74 61 74 65 6d 65 tmt">The stateme
1c20: 6e 74 20 62 65 69 6e 67 20 73 74 65 70 28 29 27 nt being step()'
1c30: 64 20 74 68 72 6f 75 67 68 3c 2f 70 61 72 61 6d d through</param
1c40: 3e 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d >. /// <param
1c50: 20 6e 61 6d 65 3d 22 69 6e 64 65 78 22 3e 54 68 name="index">Th
1c60: 65 20 63 6f 6c 75 6d 6e 20 69 6e 64 65 78 20 74 e column index t
1c70: 6f 20 72 65 74 72 69 65 76 65 3c 2f 70 61 72 61 o retrieve</para
1c80: 6d 3e 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 m>. /// <para
1c90: 6d 20 6e 61 6d 65 3d 22 74 79 70 22 3e 54 68 65 m name="typ">The
1ca0: 20 74 79 70 65 20 6f 66 20 64 61 74 61 20 63 6f type of data co
1cb0: 6e 74 61 69 6e 65 64 20 69 6e 20 74 68 65 20 63 ntained in the c
1cc0: 6f 6c 75 6d 6e 2e 20 20 49 66 20 55 6e 69 6e 69 olumn. If Unini
1cd0: 74 69 61 6c 69 7a 65 64 2c 20 74 68 69 73 20 66 tialized, this f
1ce0: 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 unction will ret
1cf0: 72 69 65 76 65 20 74 68 65 20 64 61 74 61 74 79 rieve the dataty
1d00: 70 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 3c pe information.<
1d10: 2f 70 61 72 61 6d 3e 0a 20 20 20 20 2f 2f 2f 20 /param>. ///
1d20: 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 <returns>Returns
1d30: 20 74 68 65 20 64 61 74 61 20 69 6e 20 74 68 65 the data in the
1d40: 20 63 6f 6c 75 6d 6e 3c 2f 72 65 74 75 72 6e 73 column</returns
1d50: 3e 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 76 >. internal v
1d60: 69 72 74 75 61 6c 20 20 6f 62 6a 65 63 74 20 20 irtual object
1d70: 20 47 65 74 56 61 6c 75 65 28 53 51 4c 69 74 65 GetValue(SQLite
1d80: 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 Statement stmt,
1d90: 69 6e 74 20 69 6e 64 65 78 2c 20 72 65 66 20 53 int index, ref S
1da0: 51 4c 69 74 65 54 79 70 65 20 74 79 70 29 0a 20 QLiteType typ).
1db0: 20 20 20 7b 0a 20 20 20 20 20 20 69 66 20 28 74 {. if (t
1dc0: 79 70 2e 41 66 66 69 6e 69 74 79 20 3d 3d 20 30 yp.Affinity == 0
1dd0: 29 20 74 79 70 20 3d 20 53 51 4c 69 74 65 43 6f ) typ = SQLiteCo
1de0: 6e 76 65 72 74 2e 43 6f 6c 75 6d 6e 54 6f 54 79 nvert.ColumnToTy
1df0: 70 65 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b pe(stmt, index);
1e00: 0a 20 20 20 20 20 20 69 66 20 28 49 73 4e 75 6c . if (IsNul
1e10: 6c 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 29 20 l(stmt, index))
1e20: 72 65 74 75 72 6e 20 44 42 4e 75 6c 6c 2e 56 61 return DBNull.Va
1e30: 6c 75 65 3b 0a 20 20 20 20 20 20 0a 20 20 20 20 lue;. .
1e40: 20 20 54 79 70 65 20 74 20 3d 20 53 51 4c 69 74 Type t = SQLit
1e50: 65 43 6f 6e 76 65 72 74 2e 53 51 4c 69 74 65 54 eConvert.SQLiteT
1e60: 79 70 65 54 6f 54 79 70 65 28 74 79 70 29 3b 0a ypeToType(typ);.
1e70: 0a 20 20 20 20 20 20 73 77 69 74 63 68 20 28 54 . switch (T
1e80: 79 70 65 54 6f 41 66 66 69 6e 69 74 79 28 74 29 ypeToAffinity(t)
1e90: 29 0a 20 20 20 20 20 20 7b 0a 20 20 20 20 20 20 ). {.
1ea0: 20 20 63 61 73 65 20 54 79 70 65 41 66 66 69 6e case TypeAffin
1eb0: 69 74 79 2e 42 6c 6f 62 3a 0a 20 20 20 20 20 20 ity.Blob:.
1ec0: 20 20 20 20 69 6e 74 20 6e 20 3d 20 28 69 6e 74 int n = (int
1ed0: 29 47 65 74 42 79 74 65 73 28 73 74 6d 74 2c 20 )GetBytes(stmt,
1ee0: 69 6e 64 65 78 2c 20 30 2c 20 6e 75 6c 6c 2c 20 index, 0, null,
1ef0: 30 2c 20 30 29 3b 0a 20 20 20 20 20 20 20 20 20 0, 0);.
1f00: 20 62 79 74 65 5b 5d 20 62 20 3d 20 6e 65 77 20 byte[] b = new
1f10: 62 79 74 65 5b 6e 5d 3b 0a 20 20 20 20 20 20 20 byte[n];.
1f20: 20 20 20 47 65 74 42 79 74 65 73 28 73 74 6d 74 GetBytes(stmt
1f30: 2c 20 69 6e 64 65 78 2c 20 30 2c 20 62 2c 20 30 , index, 0, b, 0
1f40: 2c 20 6e 29 3b 0a 20 20 20 20 20 20 20 20 20 20 , n);.
1f50: 72 65 74 75 72 6e 20 62 3b 0a 20 20 20 20 20 20 return b;.
1f60: 20 20 63 61 73 65 20 54 79 70 65 41 66 66 69 6e case TypeAffin
1f70: 69 74 79 2e 44 61 74 65 54 69 6d 65 3a 0a 20 20 ity.DateTime:.
1f80: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 47 return G
1f90: 65 74 44 61 74 65 54 69 6d 65 28 73 74 6d 74 2c etDateTime(stmt,
1fa0: 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 20 20 20 index);.
1fb0: 20 63 61 73 65 20 54 79 70 65 41 66 66 69 6e 69 case TypeAffini
1fc0: 74 79 2e 44 6f 75 62 6c 65 3a 0a 20 20 20 20 20 ty.Double:.
1fd0: 20 20 20 20 20 72 65 74 75 72 6e 20 43 6f 6e 76 return Conv
1fe0: 65 72 74 2e 43 68 61 6e 67 65 54 79 70 65 28 47 ert.ChangeType(G
1ff0: 65 74 44 6f 75 62 6c 65 28 73 74 6d 74 2c 20 69 etDouble(stmt, i
2000: 6e 64 65 78 29 2c 20 74 2c 20 6e 75 6c 6c 29 3b ndex), t, null);
2010: 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 54 79 . case Ty
2020: 70 65 41 66 66 69 6e 69 74 79 2e 49 6e 74 36 34 peAffinity.Int64
2030: 3a 0a 20 20 20 20 20 20 20 20 20 20 72 65 74 75 :. retu
2040: 72 6e 20 43 6f 6e 76 65 72 74 2e 43 68 61 6e 67 rn Convert.Chang
2050: 65 54 79 70 65 28 47 65 74 49 6e 74 36 34 28 73 eType(GetInt64(s
2060: 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 74 2c 20 tmt, index), t,
2070: 6e 75 6c 6c 29 3b 0a 20 20 20 20 20 20 20 20 64 null);. d
2080: 65 66 61 75 6c 74 3a 0a 20 20 20 20 20 20 20 20 efault:.
2090: 20 20 69 66 20 28 74 79 70 2e 54 79 70 65 20 3d if (typ.Type =
20a0: 3d 20 44 62 54 79 70 65 2e 47 75 69 64 29 0a 20 = DbType.Guid).
20b0: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
20c0: 6e 20 6e 65 77 20 47 75 69 64 28 47 65 74 54 65 n new Guid(GetTe
20d0: 78 74 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 29 xt(stmt, index))
20e0: 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 72 65 74 ;.. ret
20f0: 75 72 6e 20 47 65 74 54 65 78 74 28 73 74 6d 74 urn GetText(stmt
2100: 2c 20 69 6e 64 65 78 29 3b 0a 20 20 20 20 20 20 , index);.
2110: 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 69 6e 74 }. }.. int
2120: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 ernal abstract i
2130: 6e 74 20 20 43 72 65 61 74 65 43 6f 6c 6c 61 74 nt CreateCollat
2140: 69 6f 6e 28 73 74 72 69 6e 67 20 73 74 72 43 6f ion(string strCo
2150: 6c 6c 61 74 69 6f 6e 2c 20 53 51 4c 69 74 65 43 llation, SQLiteC
2160: 6f 6c 6c 61 74 69 6f 6e 20 66 75 6e 63 29 3b 0a ollation func);.
2170: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
2180: 74 72 61 63 74 20 69 6e 74 20 20 43 72 65 61 74 tract int Creat
2190: 65 46 75 6e 63 74 69 6f 6e 28 73 74 72 69 6e 67 eFunction(string
21a0: 20 73 74 72 46 75 6e 63 74 69 6f 6e 2c 20 69 6e strFunction, in
21b0: 74 20 6e 41 72 67 73 2c 20 53 51 4c 69 74 65 43 t nArgs, SQLiteC
21c0: 61 6c 6c 62 61 63 6b 20 66 75 6e 63 2c 20 53 51 allback func, SQ
21d0: 4c 69 74 65 43 61 6c 6c 62 61 63 6b 20 66 75 6e LiteCallback fun
21e0: 63 73 74 65 70 2c 20 53 51 4c 69 74 65 43 61 6c cstep, SQLiteCal
21f0: 6c 62 61 63 6b 20 66 75 6e 63 66 69 6e 61 6c 29 lback funcfinal)
2200: 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 ;. internal a
2210: 62 73 74 72 61 63 74 20 76 6f 69 64 20 46 72 65 bstract void Fre
2220: 65 46 75 6e 63 74 69 6f 6e 28 69 6e 74 20 6e 43 eFunction(int nC
2230: 6f 6f 6b 69 65 29 3b 0a 0a 20 20 20 20 69 6e 74 ookie);.. int
2240: 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 ernal abstract i
2250: 6e 74 20 41 67 67 72 65 67 61 74 65 43 6f 75 6e nt AggregateCoun
2260: 74 28 69 6e 74 20 63 6f 6e 74 65 78 74 29 3b 0a t(int context);.
2270: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 internal abs
2280: 74 72 61 63 74 20 69 6e 74 20 41 67 67 72 65 67 tract int Aggreg
2290: 61 74 65 43 6f 6e 74 65 78 74 28 69 6e 74 20 63 ateContext(int c
22a0: 6f 6e 74 65 78 74 29 3b 0a 0a 20 20 20 20 69 6e ontext);.. in
22b0: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
22c0: 6c 6f 6e 67 20 20 20 47 65 74 50 61 72 61 6d 56 long GetParamV
22d0: 61 6c 75 65 42 79 74 65 73 28 69 6e 74 20 70 74 alueBytes(int pt
22e0: 72 2c 20 69 6e 74 20 6e 44 61 74 61 4f 66 66 73 r, int nDataOffs
22f0: 65 74 2c 20 62 79 74 65 5b 5d 20 62 44 65 73 74 et, byte[] bDest
2300: 2c 20 69 6e 74 20 6e 53 74 61 72 74 2c 20 69 6e , int nStart, in
2310: 74 20 6e 4c 65 6e 67 74 68 29 3b 0a 20 20 20 20 t nLength);.
2320: 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 internal abstrac
2330: 74 20 64 6f 75 62 6c 65 20 47 65 74 50 61 72 61 t double GetPara
2340: 6d 56 61 6c 75 65 44 6f 75 62 6c 65 28 69 6e 74 mValueDouble(int
2350: 20 70 74 72 29 3b 0a 20 20 20 20 69 6e 74 65 72 ptr);. inter
2360: 6e 61 6c 20 61 62 73 74 72 61 63 74 20 69 6e 74 nal abstract int
2370: 20 20 20 20 47 65 74 50 61 72 61 6d 56 61 6c 75 GetParamValu
2380: 65 49 6e 74 33 32 28 69 6e 74 20 70 74 72 29 3b eInt32(int ptr);
2390: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 . internal ab
23a0: 73 74 72 61 63 74 20 49 6e 74 36 34 20 20 47 65 stract Int64 Ge
23b0: 74 50 61 72 61 6d 56 61 6c 75 65 49 6e 74 36 34 tParamValueInt64
23c0: 28 69 6e 74 20 70 74 72 29 3b 0a 20 20 20 20 69 (int ptr);. i
23d0: 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 nternal abstract
23e0: 20 73 74 72 69 6e 67 20 47 65 74 50 61 72 61 6d string GetParam
23f0: 56 61 6c 75 65 54 65 78 74 28 69 6e 74 20 70 74 ValueText(int pt
2400: 72 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c r);. internal
2410: 20 61 62 73 74 72 61 63 74 20 54 79 70 65 41 66 abstract TypeAf
2420: 66 69 6e 69 74 79 20 47 65 74 50 61 72 61 6d 56 finity GetParamV
2430: 61 6c 75 65 54 79 70 65 28 69 6e 74 20 70 74 72 alueType(int ptr
2440: 29 3b 0a 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c );.. internal
2450: 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 52 abstract void R
2460: 65 74 75 72 6e 42 6c 6f 62 28 69 6e 74 20 63 6f eturnBlob(int co
2470: 6e 74 65 78 74 2c 20 62 79 74 65 5b 5d 20 76 61 ntext, byte[] va
2480: 6c 75 65 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e lue);. intern
2490: 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 al abstract void
24a0: 20 52 65 74 75 72 6e 44 6f 75 62 6c 65 28 69 6e ReturnDouble(in
24b0: 74 20 63 6f 6e 74 65 78 74 2c 20 64 6f 75 62 6c t context, doubl
24c0: 65 20 76 61 6c 75 65 29 3b 0a 20 20 20 20 69 6e e value);. in
24d0: 74 65 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 ternal abstract
24e0: 76 6f 69 64 20 52 65 74 75 72 6e 45 72 72 6f 72 void ReturnError
24f0: 28 69 6e 74 20 63 6f 6e 74 65 78 74 2c 20 73 74 (int context, st
2500: 72 69 6e 67 20 76 61 6c 75 65 29 3b 0a 20 20 20 ring value);.
2510: 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 72 61 internal abstra
2520: 63 74 20 76 6f 69 64 20 52 65 74 75 72 6e 49 6e ct void ReturnIn
2530: 74 33 32 28 69 6e 74 20 63 6f 6e 74 65 78 74 2c t32(int context,
2540: 20 49 6e 74 33 32 20 76 61 6c 75 65 29 3b 0a 20 Int32 value);.
2550: 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 73 74 internal abst
2560: 72 61 63 74 20 76 6f 69 64 20 52 65 74 75 72 6e ract void Return
2570: 49 6e 74 36 34 28 69 6e 74 20 63 6f 6e 74 65 78 Int64(int contex
2580: 74 2c 20 49 6e 74 36 34 20 76 61 6c 75 65 29 3b t, Int64 value);
2590: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 61 62 . internal ab
25a0: 73 74 72 61 63 74 20 76 6f 69 64 20 52 65 74 75 stract void Retu
25b0: 72 6e 4e 75 6c 6c 28 69 6e 74 20 63 6f 6e 74 65 rnNull(int conte
25c0: 78 74 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e 61 xt);. interna
25d0: 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 20 l abstract void
25e0: 52 65 74 75 72 6e 54 65 78 74 28 69 6e 74 20 63 ReturnText(int c
25f0: 6f 6e 74 65 78 74 2c 20 73 74 72 69 6e 67 20 76 ontext, string v
2600: 61 6c 75 65 29 3b 0a 0a 20 20 20 20 69 6e 74 65 alue);.. inte
2610: 72 6e 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f rnal abstract vo
2620: 69 64 20 53 65 74 50 61 73 73 77 6f 72 64 28 62 id SetPassword(b
2630: 79 74 65 5b 5d 20 70 61 73 73 77 6f 72 64 42 79 yte[] passwordBy
2640: 74 65 73 29 3b 0a 20 20 20 20 69 6e 74 65 72 6e tes);. intern
2650: 61 6c 20 61 62 73 74 72 61 63 74 20 76 6f 69 64 al abstract void
2660: 20 43 68 61 6e 67 65 50 61 73 73 77 6f 72 64 28 ChangePassword(
2670: 62 79 74 65 5b 5d 20 6e 65 77 50 61 73 73 77 6f byte[] newPasswo
2680: 72 64 42 79 74 65 73 29 3b 0a 0a 20 20 20 20 70 rdBytes);.. p
2690: 72 6f 74 65 63 74 65 64 20 76 69 72 74 75 61 6c rotected virtual
26a0: 20 76 6f 69 64 20 44 69 73 70 6f 73 65 28 62 6f void Dispose(bo
26b0: 6f 6c 20 62 44 69 73 70 6f 73 69 6e 67 29 0a 20 ol bDisposing).
26c0: 20 20 20 7b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 {. }..
26d0: 70 75 62 6c 69 63 20 76 6f 69 64 20 44 69 73 70 public void Disp
26e0: 6f 73 65 28 29 0a 20 20 20 20 7b 0a 20 20 20 20 ose(). {.
26f0: 20 20 44 69 73 70 6f 73 65 28 74 72 75 65 29 3b Dispose(true);
2700: 0a 20 20 20 20 20 20 47 43 2e 53 75 70 70 72 65 . GC.Suppre
2710: 73 73 46 69 6e 61 6c 69 7a 65 28 74 68 69 73 29 ssFinalize(this)
2720: 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 7d 0a ;. }. }.}.