System.Data.SQLite
Check-in [4453746b7a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:1.0.14
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 4453746b7a88ee64b9ed6214e01cfa47f3e8797d
User & Date: rmsimpson 2005-08-16 19:12:43
Context
2005-08-17
21:13
Event optimizations using generics check-in: 1b0be7f408 user: rmsimpson tags: sourceforge
2005-08-16
19:12
1.0.14 check-in: 4453746b7a user: rmsimpson tags: sourceforge
19:09
1.0.14 Designer support check-in: f31df8c30b user: rmsimpson tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Doc/SQLite.NET.chm.

cannot compute difference between binary files

Added SQLite.Designer/AssemblyInfo.cs.















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SQLite.Designer")]
[assembly: AssemblyDescription("ADO.NET 2.0 Data Designer for SQLite")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://sourceforge.net/projects/sqlite-dotnet2")]
[assembly: AssemblyProduct("SQLite.Designer")]
[assembly: AssemblyCopyright("Public Domain")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM componenets.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.14.0")]
[assembly: AssemblyFileVersion("1.0.14.0")]
[assembly:AssemblyDelaySignAttribute(false)]
[assembly:AssemblyKeyFileAttribute("..\\System.Data.SQLite\\System.Data.SQLite.snk")]
[assembly:AssemblyKeyNameAttribute("")]

Added SQLite.Designer/SQLite.Designer.csproj.





































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50215</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SQLite.Designer</RootNamespace>
    <AssemblyName>SQLite.Designer</AssemblyName>
    <SignAssembly>false</SignAssembly>
    <AssemblyOriginatorKeyFile>
    </AssemblyOriginatorKeyFile>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\bin\Designer\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <NoWarn>1701;1702;1699</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>..\bin\Designer\</OutputPath>
    <DefineConstants>
    </DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <NoWarn>1701;1702;1699</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.VisualStudio.Data, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\VSNET2005\Common7\IDE\Microsoft.VisualStudio.Data.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="SQLiteDataObjectIdentifierResolver.cs" />
    <Compile Include="SQLiteDataSourceInformation.cs" />
    <Compile Include="AssemblyInfo.cs" />
    <Compile Include="SR.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>SR.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="SR.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>SR.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

Added SQLite.Designer/SQLiteDataObjectIdentifierResolver.cs.

















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
namespace SQLite.Designer
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;

  internal class SQLiteDataObjectIdentifierResolver : DataObjectIdentifierResolver, IObjectWithSite
  {
    private DataConnection _connection;

    public SQLiteDataObjectIdentifierResolver()
    {
    }

    protected override object[] QuickExpandIdentifier(string typeName, object[] partialIdentifier)
    {
      if (typeName == null)
      {
        throw new ArgumentNullException("typeName");
      }

      // Create an identifier array of the correct full length based on
      // the object type
      object[] identifier = null;
      int length = 0;

      switch (typeName.ToLowerInvariant())
      {
        case "":
          length = 0;
          break;
        case "table":
        case "view":
          length = 3;
          break;
        case "column":
        case "index":
        case "foreignkey":
        case "viewcolumn":
          length = 4;
          break;
        //case SqlDataObjectTypes.IndexColumn:
        //case SqlDataObjectTypes.ForeignKeyColumn:
        //  length = 5;
        //  break;
        default:
          throw new NotSupportedException();
      }
      identifier = new object[length];

      // If the input identifier is not null, copy it to the full
      // identifier array.  If the input identifier's length is less
      // than the full length we assume the more specific parts are
      // specified and thus copy into the rightmost portion of the
      // full identifier array.
      if (partialIdentifier != null)
      {
        if (partialIdentifier.Length > length)
        {
          throw new InvalidOperationException();
        }
        partialIdentifier.CopyTo(identifier, length - partialIdentifier.Length);
      }

      if (length > 0)
      {
        // Fill in the current database if not specified
        if (!(identifier[0] is string))
        {
          identifier[0] = _connection.SourceInformation[DataSourceInformation.DefaultCatalog] as string;
        }
      }

      if (length > 1)
      {
        identifier[1] = null;
      }

      return identifier;
    }

    protected override object[] QuickContractIdentifier(string typeName, object[] fullIdentifier)
    {
      int length = fullIdentifier.Length;
      object[] identifier = new object[length];

      fullIdentifier.CopyTo(identifier, 0);

      if (length > 0)
      {
        if (!(identifier[0] is string))
          identifier[0] = null;
      }

      if (length > 1)
      {
        identifier[1] = null;
      }

      return identifier;
    }

    /// <summary>
    /// GetSite does not need to be implemented since
    /// DDEX only calls SetSite to site the object.
    /// </summary>
    void IObjectWithSite.GetSite(ref Guid riid, out IntPtr ppvSite)
    {
      ppvSite = IntPtr.Zero;
      throw new NotImplementedException();
    }

    void IObjectWithSite.SetSite(object pUnkSite)
    {
      _connection = (DataConnection)pUnkSite;
    }
  }
}

Added SQLite.Designer/SQLiteDataSourceInformation.cs.













































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace SQLite.Designer
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;

  internal class SQLiteDataSourceInformation : DataSourceInformation
  {
    public SQLiteDataSourceInformation()
    {
      Initialize();
    }

    public SQLiteDataSourceInformation(DataConnection connection) : base(connection)
    {
      Initialize();
    }

    private void Initialize()
    {
      AddProperty(DefaultSchema);
      AddProperty(DefaultCatalog, "main");
      AddProperty(SupportsAnsi92Sql, true);
      AddProperty(SupportsQuotedIdentifierParts, false);
      AddProperty(IdentifierOpenQuote, "[");
      AddProperty(IdentifierCloseQuote, "]");
      AddProperty(CatalogSeparator, ".");
      AddProperty(CatalogSupported, true);
      AddProperty(CatalogSupportedInDml, true);
      AddProperty(SchemaSupported, false);
      AddProperty(SchemaSupportedInDml, false);
      AddProperty(SchemaSeparator, "");
      AddProperty(ParameterPrefix, "$");
      AddProperty(ParameterPrefixInName, true);
    }
  }
}

Added SQLite.Designer/SR.Designer.cs.











































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50215.44
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="SQLite.Designer.SR.get_ResourceManager():System.Resources.ResourceManager")]
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="SQLite.Designer.SR.get_Culture():System.Globalization.CultureInfo")]
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="SQLite.Designer.SR.set_Culture(System.Globalization.CultureInfo):Void")]

namespace SQLite.Designer {
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class SR {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal SR() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if ((resourceMan == null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLite.Designer.SR", typeof(SR).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to .NET Data Provider for SQLite.
        /// </summary>
        internal static string DataProvider_SQLite {
            get {
                return ResourceManager.GetString("DataProvider_SQLite", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Description of the SQLite Data Provider goes here.
        /// </summary>
        internal static string DataProvider_SQLite_Description {
            get {
                return ResourceManager.GetString("DataProvider_SQLite_Description", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Service Provider string.
        /// </summary>
        internal static string DataProvider_SQLite_ServiceProvider {
            get {
                return ResourceManager.GetString("DataProvider_SQLite_ServiceProvider", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SQLite Database File.
        /// </summary>
        internal static string DataProvider_SQLite_Short {
            get {
                return ResourceManager.GetString("DataProvider_SQLite_Short", resourceCulture);
            }
        }
    }
}

Added SQLite.Designer/SR.resx.



































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="DataProvider_SQLite">
    <value xml:space="preserve">.NET Data Provider for SQLite</value>
  </data>
  <data name="DataProvider_SQLite_Description">
    <value xml:space="preserve">Description of the SQLite Data Provider goes here</value>
  </data>
  <data name="DataProvider_SQLite_ServiceProvider">
    <value xml:space="preserve">Service Provider string</value>
  </data>
  <data name="DataProvider_SQLite_Short">
    <value xml:space="preserve">SQLite Database File</value>
  </data>
</root>

Changes to SQLite.Interop/AssemblyInfo.cpp.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
49
50
51
52
53
54
55
56
57
58
59
60
61
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("1.0.12.*")];

//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft CLR Framework documentation for more information on assembly signing.
//
// You can use the attributes below to control which key is used for signing.
// You can also use the project property page for signing under Common Properties
................................................................................
//           in the KeyFile is installed into the CSP and used.
//   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
//        When specifying the KeyFile, the location of the KeyFile should be
//        relative to the project directory.
//   (*) Delay Signing is an advanced option - see the Microsoft CLR Framework
//       documentation for more information on this.
//
//[assembly:AssemblyDelaySignAttribute(false)];
//[assembly:AssemblyKeyFileAttribute("")];
//[assembly:AssemblyKeyNameAttribute("")];

[assembly:ComVisible(false)];








|







 







|
|
|



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
49
50
51
52
53
54
55
56
57
58
59
60
61
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("1.0.14.0")];

//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft CLR Framework documentation for more information on assembly signing.
//
// You can use the attributes below to control which key is used for signing.
// You can also use the project property page for signing under Common Properties
................................................................................
//           in the KeyFile is installed into the CSP and used.
//   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
//        When specifying the KeyFile, the location of the KeyFile should be
//        relative to the project directory.
//   (*) Delay Signing is an advanced option - see the Microsoft CLR Framework
//       documentation for more information on this.
//
[assembly:AssemblyDelaySignAttribute(false)];
[assembly:AssemblyKeyFileAttribute("..\\System.Data.SQLite\\System.Data.SQLite.snk")];
[assembly:AssemblyKeyNameAttribute("")];

[assembly:ComVisible(false)];

Changes to SQLite.Interop/SQLite.Interop.rc.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 3,2,2,0
 PRODUCTVERSION 1,0,12,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
................................................................................
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sourceforge.net/projects/sqlite-dotnet2"
            VALUE "FileDescription", "SQLite.NET Interop Library"
            VALUE "FileVersion", "3.2.2"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL"
            VALUE "ProductName", "SQLite.NET"
            VALUE "ProductVersion", "1.0.12"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END







|
|







 







|


|

|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,14,0
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
................................................................................
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sourceforge.net/projects/sqlite-dotnet2"
            VALUE "FileDescription", "SQLite.NET Interop Library"
            VALUE "FileVersion", "1.0.14"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL v3.22"
            VALUE "ProductName", "SQLite.NET"
            VALUE "ProductVersion", "1.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

Changes to SQLite.NET.sln.

16
17
18
19
20
21
22


23
24
25
26
27
28
29
..
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61








62
63
64
65
66
		readme.htm = readme.htm
	EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite.Interop", "SQLite.Interop\SQLite.Interop.vcproj", "{10B51CE8-A838-44DE-BD82-B658F0296F80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testce", "testce\testce.csproj", "{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}"
EndProject


Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Compact Framework = Debug|Compact Framework
		Debug|Win32 = Debug|Win32
		Release|Compact Framework = Release|Compact Framework
		Release|Win32 = Release|Win32
	EndGlobalSection
................................................................................
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Compact Framework.ActiveCfg = Release|Any CPU
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.ActiveCfg = Release|Any CPU
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.Build.0 = Release|Any CPU
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.Build.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.ActiveCfg = Release|Win32

		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.Build.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.ActiveCfg = Release|Win32
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.Build.0 = Release|Win32
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.ActiveCfg = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.Build.0 = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.Deploy.0 = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Win32.ActiveCfg = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.ActiveCfg = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.Build.0 = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.Deploy.0 = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Win32.ActiveCfg = Release|Any CPU








	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal







>
>







 







>













>
>
>
>
>
>
>
>





16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
		readme.htm = readme.htm
	EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite.Interop", "SQLite.Interop\SQLite.Interop.vcproj", "{10B51CE8-A838-44DE-BD82-B658F0296F80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testce", "testce\testce.csproj", "{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite.Designer", "SQLite.Designer\SQLite.Designer.csproj", "{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Compact Framework = Debug|Compact Framework
		Debug|Win32 = Debug|Win32
		Release|Compact Framework = Release|Compact Framework
		Release|Win32 = Release|Win32
	EndGlobalSection
................................................................................
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Compact Framework.ActiveCfg = Release|Any CPU
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.ActiveCfg = Release|Any CPU
		{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.Build.0 = Release|Any CPU
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.Build.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.ActiveCfg = Release|Win32
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.Build.0 = Release|Win32
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.Build.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.ActiveCfg = Release|Win32
		{10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.Build.0 = Release|Win32
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.ActiveCfg = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.Build.0 = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework.Deploy.0 = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Win32.ActiveCfg = Debug|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.ActiveCfg = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.Build.0 = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework.Deploy.0 = Release|Any CPU
		{B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Win32.ActiveCfg = Release|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Debug|Compact Framework.ActiveCfg = Debug|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Debug|Compact Framework.Build.0 = Debug|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Debug|Win32.ActiveCfg = Debug|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Debug|Win32.Build.0 = Debug|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Release|Compact Framework.ActiveCfg = Release|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Release|Compact Framework.Build.0 = Release|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Release|Win32.ActiveCfg = Release|Any CPU
		{9B4A5CF6-5BE5-4926-ACC7-B729A8C05198}.Release|Win32.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

Changes to System.Data.SQLite/AssemblyInfo.cs.

35
36
37
38
39
40
41
42
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.12.*")]







|
35
36
37
38
39
40
41
42
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.14.0")]

Changes to System.Data.SQLite/SQLite3.cs.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
...
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Runtime.InteropServices;
  using System.Collections.Generic;


  /// <summary>
  /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET
  /// </summary>
  internal class SQLite3 : SQLiteBase
  {
    /// <summary>
................................................................................
    /// </summary>
    protected int              _sql;
    /// <summary>
    /// The user-defined functions registered on this connection
    /// </summary>
    protected SQLiteFunction[] _functionsArray;

    internal SQLite3(DateTimeFormat fmt)
      : base(fmt)
    {
    }

    protected override void Dispose(bool bDisposing)
    {
      Close();
................................................................................

    internal override int ColumnIndex(SQLiteStatement stmt, string columnName)
    {
      int x = ColumnCount(stmt);

      for (int n = 0; n < x; n++)
      {
        if (String.Compare(columnName, ColumnName(stmt, n), true, System.Globalization.CultureInfo.CurrentCulture) == 0) return n;

      }
      return -1;
    }

    internal override double GetDouble(SQLiteStatement stmt, int index)
    {
      double value;







>







 







|







 







|
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Runtime.InteropServices;
  using System.Collections.Generic;
  using System.Globalization;

  /// <summary>
  /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET
  /// </summary>
  internal class SQLite3 : SQLiteBase
  {
    /// <summary>
................................................................................
    /// </summary>
    protected int              _sql;
    /// <summary>
    /// The user-defined functions registered on this connection
    /// </summary>
    protected SQLiteFunction[] _functionsArray;

    internal SQLite3(SQLiteDateFormats fmt)
      : base(fmt)
    {
    }

    protected override void Dispose(bool bDisposing)
    {
      Close();
................................................................................

    internal override int ColumnIndex(SQLiteStatement stmt, string columnName)
    {
      int x = ColumnCount(stmt);

      for (int n = 0; n < x; n++)
      {
        if (String.Compare(columnName, ColumnName(stmt, n), true, CultureInfo.CurrentCulture) == 0)
          return n;
      }
      return -1;
    }

    internal override double GetDouble(SQLiteStatement stmt, int index)
    {
      double value;

Changes to System.Data.SQLite/SQLite3_UTF16.cs.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  using System.Runtime.InteropServices;

  /// <summary>
  /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode)
  /// </summary>
  internal class SQLite3_UTF16 : SQLite3
  {
    internal SQLite3_UTF16(DateTimeFormat fmt)
      : base(fmt)
    {
    }

    /// <summary>
    /// Overrides SQLiteConvert.ToString() to marshal UTF-16 strings instead of UTF-8
    /// </summary>







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  using System.Runtime.InteropServices;

  /// <summary>
  /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode)
  /// </summary>
  internal class SQLite3_UTF16 : SQLite3
  {
    internal SQLite3_UTF16(SQLiteDateFormats fmt)
      : base(fmt)
    {
    }

    /// <summary>
    /// Overrides SQLiteConvert.ToString() to marshal UTF-16 strings instead of UTF-8
    /// </summary>

Changes to System.Data.SQLite/SQLiteBase.cs.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

  /// <summary>
  /// This internal class provides the foundation of SQLite support.  It defines all the abstract members needed to implement
  /// a SQLite data provider, and inherits from SQLiteConvert which allows for simple translations of string to and from SQLite.
  /// </summary>
  internal abstract class SQLiteBase : SQLiteConvert, IDisposable
  {
    internal SQLiteBase(DateTimeFormat fmt)
      : base(fmt) {}

    /// <summary>
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }
    /// <summary>







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

  /// <summary>
  /// This internal class provides the foundation of SQLite support.  It defines all the abstract members needed to implement
  /// a SQLite data provider, and inherits from SQLiteConvert which allows for simple translations of string to and from SQLite.
  /// </summary>
  internal abstract class SQLiteBase : SQLiteConvert, IDisposable
  {
    internal SQLiteBase(SQLiteDateFormats fmt)
      : base(fmt) {}

    /// <summary>
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }
    /// <summary>

Changes to System.Data.SQLite/SQLiteCommand.cs.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
360
361
362
363
364
365
366
367
368
369



















370
371
372
373
374
375
376
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
...
471
472
473
474
475
476
477
478










479




  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;

  /// <summary>
  /// SQLite implementation of DbCommand.
  /// </summary>
  public sealed class SQLiteCommand : DbCommand
  {
    /// <summary>
    /// The command text this command is based on
    /// </summary>
    private string                    _commandText;
    /// <summary>
    /// The connection the command is associated with
    /// </summary>
    private SQLiteConnection          _cnn;
    /// <summary>
    /// Indicates whether or not a DataReader is active on the command.
    /// </summary>
    private bool                      _isReaderOpen;
    /// <summary>
    /// The timeout for the command, kludged because SQLite doesn't support per-command timeout values
    /// </summary>
    internal int                       _commandTimeout;
    /// <summary>
    /// Designer support
    /// </summary>
    private bool                      _designTimeVisible;
    /// <summary>
    /// Used by DbDataAdapter to determine updating behavior
    /// </summary>
    private UpdateRowSource           _updateRowSource;
    /// <summary>
    /// The collection of parameters for the command
    /// </summary>
    private SQLiteParameterCollection _parameterCollection;
    /// <summary>
    /// The SQL command text, broken into individual SQL statements
    /// </summary>
    internal SQLiteStatement[]        _statementList;

    ///<overloads>
    /// Constructs a new SQLiteCommand
    /// </overloads>
    /// <summary>
    /// Default constructor
    /// </summary>
................................................................................
    /// <returns>Returns a SQLiteDataReader object</returns>
    protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
    {
      InitializeForReader();

      SQLiteDataReader rd = new SQLiteDataReader(this, behavior);
      _isReaderOpen = true;
        
      return rd;
    }




















    /// <summary>
    /// Called by the SQLiteDataReader when the data reader is closed.
    /// </summary>
    internal void ClearDataReader()
    {
      _isReaderOpen = false;
................................................................................
      return nAffected;
    }

    /// <summary>
    /// Execute the command and return the first column of the first row of the resultset
    /// (if present), or null if no resultset was returned.
    /// </summary>
    /// <returns></returns>
    public override object ExecuteScalar()
    {
      InitializeForReader();

      int n;
      int x;
      object ret = null;
................................................................................
        return _designTimeVisible;
      }
      set
      {
        _designTimeVisible = value;
      }
    }
  }










}











|




|



|



|



|



|



|







|







 







|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







|
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
...
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;

  /// <summary>
  /// SQLite implementation of DbCommand.
  /// </summary>
  public sealed class SQLiteCommand : DbCommand, ICloneable
  {
    /// <summary>
    /// The command text this command is based on
    /// </summary>
    private string _commandText;
    /// <summary>
    /// The connection the command is associated with
    /// </summary>
    private SQLiteConnection _cnn;
    /// <summary>
    /// Indicates whether or not a DataReader is active on the command.
    /// </summary>
    private bool _isReaderOpen;
    /// <summary>
    /// The timeout for the command, kludged because SQLite doesn't support per-command timeout values
    /// </summary>
    internal int _commandTimeout;
    /// <summary>
    /// Designer support
    /// </summary>
    private bool _designTimeVisible;
    /// <summary>
    /// Used by DbDataAdapter to determine updating behavior
    /// </summary>
    private UpdateRowSource _updateRowSource;
    /// <summary>
    /// The collection of parameters for the command
    /// </summary>
    private SQLiteParameterCollection _parameterCollection;
    /// <summary>
    /// The SQL command text, broken into individual SQL statements
    /// </summary>
    internal SQLiteStatement[] _statementList;

    ///<overloads>
    /// Constructs a new SQLiteCommand
    /// </overloads>
    /// <summary>
    /// Default constructor
    /// </summary>
................................................................................
    /// <returns>Returns a SQLiteDataReader object</returns>
    protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
    {
      InitializeForReader();

      SQLiteDataReader rd = new SQLiteDataReader(this, behavior);
      _isReaderOpen = true;

      return rd;
    }

    /// <summary>
    /// Overrides the default behavior to return a SQLiteDataReader specialization class
    /// </summary>
    /// <param name="behavior">The flags to be associated with the reader</param>
    /// <returns>A SQLiteDataReader</returns>
    public new SQLiteDataReader ExecuteReader(CommandBehavior behavior)
    {
      return (SQLiteDataReader)ExecuteDbDataReader(behavior);
    }

    /// <summary>
    /// Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class
    /// </summary>
    /// <returns>A SQLiteDataReader</returns>
    public new SQLiteDataReader ExecuteReader()
    {
      return (SQLiteDataReader)ExecuteDbDataReader(CommandBehavior.Default);
    }

    /// <summary>
    /// Called by the SQLiteDataReader when the data reader is closed.
    /// </summary>
    internal void ClearDataReader()
    {
      _isReaderOpen = false;
................................................................................
      return nAffected;
    }

    /// <summary>
    /// Execute the command and return the first column of the first row of the resultset
    /// (if present), or null if no resultset was returned.
    /// </summary>
    /// <returns>The first column of the first row of the first resultset from the query</returns>
    public override object ExecuteScalar()
    {
      InitializeForReader();

      int n;
      int x;
      object ret = null;
................................................................................
        return _designTimeVisible;
      }
      set
      {
        _designTimeVisible = value;
      }
    }

    /// <summary>
    /// Clones a command, including all its parameters
    /// </summary>
    /// <returns>A new SQLiteCommand with the same commandtext, connection and parameters</returns>
    public object Clone()
    {
      SQLiteCommand newcommand = new SQLiteCommand(CommandText, Connection as SQLiteConnection);
      foreach (SQLiteParameter param in _parameterCollection)
      {
        newcommand.Parameters.Add(param.Clone());
      }
      return newcommand;
    }
  }
}

Changes to System.Data.SQLite/SQLiteCommandBuilder.cs.

12
13
14
15
16
17
18


19
20
21
22
23
24
25
..
37
38
39
40
41
42
43


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85


86
87







  using System.Data.Common;

  /// <summary>
  /// SQLite implementation of DbCommandBuilder.
  /// </summary>
  public sealed class SQLiteCommandBuilder : DbCommandBuilder
  {


    /// <summary>
    /// Default constructor
    /// </summary>
    public SQLiteCommandBuilder()
    {
    }

................................................................................
    /// </summary>
    /// <param name="parameter">The parameter to use in applying custom behaviors to a row</param>
    /// <param name="row">The row to apply the parameter to</param>
    /// <param name="statementType">The type of statement</param>
    /// <param name="whereClause">Whether the application of the parameter is part of a WHERE clause</param>
    protected override void ApplyParameterInfo(DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
    {


    }

    /// <overloads>
    /// Not implemented.  Throws a NotImplementedException() if called.
    /// </overloads>
    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="parameterName">The name of the parameter</param>
    /// <returns>Error</returns>
    protected override string GetParameterName(string parameterName)
    {
      throw new NotImplementedException();
    }

    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="parameterOrdinal">The i of the parameter</param>
    /// <returns>Error</returns>
    protected override string GetParameterName(int parameterOrdinal)
    {
      return null;
    }

    /// <summary>
    /// Returns a placeholder character for the specified parameter i.
    /// </summary>
    /// <param name="parameterOrdinal">The index of the parameter to provide a placeholder for</param>
    /// <returns>Returns a "?" character, used for all placeholders.</returns>
    protected override string GetParameterPlaceholder(int parameterOrdinal)
    {
      return "?";
    }

    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="adapter">A data adapter to receive events on.</param>
    protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
    {

    }


  }
}














>
>







 







>
>












|









|









|








>
|
>
>
|
|
>
>
>
>
>
>
>
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  using System.Data.Common;

  /// <summary>
  /// SQLite implementation of DbCommandBuilder.
  /// </summary>
  public sealed class SQLiteCommandBuilder : DbCommandBuilder
  {
    private SQLiteRowUpdatingEventHandler _handler;

    /// <summary>
    /// Default constructor
    /// </summary>
    public SQLiteCommandBuilder()
    {
    }

................................................................................
    /// </summary>
    /// <param name="parameter">The parameter to use in applying custom behaviors to a row</param>
    /// <param name="row">The row to apply the parameter to</param>
    /// <param name="statementType">The type of statement</param>
    /// <param name="whereClause">Whether the application of the parameter is part of a WHERE clause</param>
    protected override void ApplyParameterInfo(DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
    {
      SQLiteParameter param = (SQLiteParameter)parameter;
      param.DbType = (DbType)row[SchemaTableColumn.ProviderType];
    }

    /// <overloads>
    /// Not implemented.  Throws a NotImplementedException() if called.
    /// </overloads>
    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="parameterName">The name of the parameter</param>
    /// <returns>Error</returns>
    protected override string GetParameterName(string parameterName)
    {
      return String.Format(System.Globalization.CultureInfo.InvariantCulture, "${0}", parameterName);
    }

    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="parameterOrdinal">The i of the parameter</param>
    /// <returns>Error</returns>
    protected override string GetParameterName(int parameterOrdinal)
    {
      return String.Format(System.Globalization.CultureInfo.InvariantCulture, "$param{0}", parameterOrdinal);
    }

    /// <summary>
    /// Returns a placeholder character for the specified parameter i.
    /// </summary>
    /// <param name="parameterOrdinal">The index of the parameter to provide a placeholder for</param>
    /// <returns>Returns a "?" character, used for all placeholders.</returns>
    protected override string GetParameterPlaceholder(int parameterOrdinal)
    {
      return GetParameterName(parameterOrdinal);
    }

    /// <summary>
    /// Not implemented.
    /// </summary>
    /// <param name="adapter">A data adapter to receive events on.</param>
    protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
    {
      SQLiteDataAdapter adp = (SQLiteDataAdapter)adapter;

      _handler = new SQLiteRowUpdatingEventHandler(RowUpdatingEventHandler);
      adp.RowUpdating += _handler;
    }

    private void RowUpdatingEventHandler(object sender, RowUpdatingEventArgs e)
    {
      base.RowUpdatingHandler(e);
    }

  }
}

Changes to System.Data.SQLite/SQLiteConnection.cs.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24
25
...
105
106
107
108
109
110
111




112
113
114
115
116
117
118
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
...
354
355
356
357
358
359
360
361
362
363
364


365

366
367
368
369
370
371
372


373

374
375
376
377
378
379
380
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
...
436
437
438
439
440
441
442
443
444
445





446
447
448
449

450
451
452

453
454

455
456


457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
...
488
489
490
491
492
493
494


495

496
497
498
499
500
501
502
...
552
553
554
555
556
557
558
559
560
561
562
563
564




565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
...
596
597
598
599
600
601
602








603
604
605
606
607
608
609
...
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
...
656
657
658
659
660
661
662
663
664
665
666
667
668
669


670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
...
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
...
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742

743
744
745
746
747
748
749
750
751
752
753
754

755
756
757
758
759
760
761
...
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
...
805
806
807
808
809
810
811
812
813
814
815
816
817
818

819
820

821
822

823
824
825
826
827
828
829
...
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878

879
880

881
882

883
884
885
886
887
888
889
...
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934

935
936
937
938
939
940
941

942
943
944
945
946
947
948
949
950
951
...
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982

983
984

985

986
987
988
989
990
991
992
993
994
995
996
997





998























































































































































































































































namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;


  /// <summary>
  /// The I/O file cache flushing behavior for the connection
  /// </summary>
  public enum SyncMode
  {
    /// <summary>
    /// Normal file flushing at critical sections of the code
    /// </summary>
    Normal = 0,
    /// <summary>
    /// Full file flushing after every write operation
................................................................................
    /// The base SQLite object to interop with
    /// </summary>
    internal SQLiteBase          _sql;
    /// <summary>
    /// Commands associated with this connection
    /// </summary>
    internal List<SQLiteCommand> _commandList;





    /// <event/>
    /// <summary>
    /// This event is raised whenever the database is opened or closed.
    /// </summary>
    public override event StateChangeEventHandler StateChange;

................................................................................

        // Reattach all attached databases from the existing connection
        using (DataTable tbl = cnn.GetSchema("Catalogs"))
        {
          foreach (DataRow row in tbl.Rows)
          {
            str = row[0].ToString();
            if (String.Compare(str, "MAIN", true, System.Globalization.CultureInfo.InvariantCulture) != 0
              && String.Compare(str, "TEMP", true, System.Globalization.CultureInfo.InvariantCulture) != 0)
            {
              _sql.Execute(String.Format(System.Globalization.CultureInfo.InvariantCulture, "ATTACH DATABASE '{0}' AS [{1}]", row[1], row[0]));
            }
          }
        }
      }
    }
................................................................................
    /// <returns>Returns an instantiated SQLiteCommand object already assigned to this connection.</returns>
    protected override DbCommand CreateDbCommand()
    {
      return new SQLiteCommand(this);
    }

    /// <summary>
    /// Not implemented.  Returns null.
    /// </summary>
    public override string DataSource
    {


      get { return null; }

    }

    /// <summary>
    /// Not implemented.  Returns null.
    /// </summary>
    public override string Database
    {


      get { return null; }

    }

    /// <summary>
    /// Parses the connection string into component parts
    /// </summary>
    /// <returns>An array of key-value pairs representing each parameter of the connection string</returns>
    internal KeyValuePair<string, string>[] ParseConnectionString()
................................................................................
    /// <param name="defValue">The default value to return if the key is not found</param>
    /// <returns>The value corresponding to the specified key, or the default value if not found.</returns>
    static internal string FindKey(KeyValuePair<string, string>[] opts, string key, string defValue)
    {
      int x = opts.Length;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(opts[n].Key, key, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
        {
          return opts[n].Value;
        }
      }
      return defValue;
    }

................................................................................
      if (_connectionState != ConnectionState.Closed)
        throw new InvalidOperationException();

      Close();

      KeyValuePair<string, string>[] opts = ParseConnectionString();

      if (Convert.ToInt32(FindKey(opts, "Version", "3"), System.Globalization.CultureInfo.InvariantCulture) != 3)
        throw new NotSupportedException("Only SQLite Version 3 is supported at this time");






      try
      {
        string strFile = FindKey(opts, "Data Source", "");
        bool bUTF16 = (Convert.ToBoolean(FindKey(opts, "UseUTF16Encoding", "False"), System.Globalization.CultureInfo.InvariantCulture) == true);


        if (bUTF16)
          _sql = new SQLite3_UTF16(String.Compare(FindKey(opts, "DateTimeFormat", "ISO8601"), "TICKS", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? DateTimeFormat.Ticks : DateTimeFormat.ISO8601);

        else
          _sql = new SQLite3(String.Compare(FindKey(opts, "DateTimeFormat", "ISO8601"), "TICKS", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? DateTimeFormat.Ticks : DateTimeFormat.ISO8601);


        _sql.Open(strFile);



        if (bUTF16 == true)
          _sql.Execute("PRAGMA encoding = 'UTF-16'");
        else
          _sql.Execute("PRAGMA encoding = 'UTF-8'");

        _sql.Execute(String.Format(System.Globalization.CultureInfo.InvariantCulture, "PRAGMA Synchronous={0}", FindKey(opts, "Synchronous", "Normal")));
        _sql.Execute(String.Format(System.Globalization.CultureInfo.InvariantCulture, "PRAGMA Cache_Size={0}", FindKey(opts, "Cache Size", "2000")));
        if (String.Compare(strFile, ":MEMORY:", true, System.Globalization.CultureInfo.InvariantCulture) != 0)
          _sql.Execute(String.Format(System.Globalization.CultureInfo.InvariantCulture, "PRAGMA Page_Size={0}", FindKey(opts, "Page Size", "1024")));
      }
      catch (SQLiteException)
      {
        OnStateChange(ConnectionState.Broken);
        throw;
      }
      OnStateChange(ConnectionState.Open);
................................................................................
    }

    /// <summary>
    /// Returns the state of the connection.
    /// </summary>
    public override ConnectionState State
    {


      get { return _connectionState; }

    }

    ///<overloads>
    /// The following commands are used to extract schema information out of the database.  Valid schema types are:
    /// <list type="bullet">
    /// <item>
    /// <description>MetaDataCollections</description>
................................................................................
        throw new InvalidOperationException();

      string[] parms = new string[5];

      restrictionValues.CopyTo(parms, 0);

      if (restrictionValues == null) restrictionValues = new string[0];
      switch (collectionName.ToUpper(System.Globalization.CultureInfo.InvariantCulture))
      {
        case "METADATACOLLECTIONS":
          return Schema_MetaDataCollections();
        case "DATASOURCEINFORMATION":
          return Schema_DataSourceInformation();




        case "COLUMNS":
          return Schema_Columns(parms[0], parms[2], parms[3]);
        case "INDEXES":
          return Schema_Indexes(parms[0], parms[2], parms[4]);
        case "TABLES":
          return Schema_Tables(parms[0], parms[2], parms[3]);
        case "VIEWS":
          return Schema_Views(parms[0], parms[2]);
        case "CATALOGS":
          return Schema_Catalogs(parms[0]);
      }
      return null;
    }

    /// <summary>
    /// Builds a MetaDataCollections schema datatable
    /// </summary>
    /// <returns>DataTable</returns>
    private static DataTable Schema_MetaDataCollections()
    {
      DataTable tbl = new DataTable("MetaDataCollections");
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("CollectionName", typeof(string));
      tbl.Columns.Add("NumberOfRestrictions", typeof(int));
      tbl.Columns.Add("NumberOfIdentifierParts", typeof(int));

      tbl.BeginLoadData();

      row = tbl.NewRow();
................................................................................
      row.ItemArray = new object[] { "MetaDataCollections", 0, 0 };
      tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "DataSourceInformation", 0, 0 };
      tbl.Rows.Add(row);









      row = tbl.NewRow();
      row.ItemArray = new object[] { "Catalogs", 1, 1 };
      tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "Columns", 4, 4 };
      tbl.Rows.Add(row);
................................................................................
    /// </summary>
    /// <returns>DataTable</returns>
    private DataTable Schema_DataSourceInformation()
    {
      DataTable tbl = new DataTable("DataSourceInformation");
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("CompositeIdentifierSeparatorPattern", typeof(string));
      tbl.Columns.Add("DataSourceProductName", typeof(string));
      tbl.Columns.Add("DataSourceProductVersion", typeof(string));
      tbl.Columns.Add("DataSourceProductVersionNormalized", typeof(string));
      tbl.Columns.Add("GroupByBehavior", typeof(int));
      tbl.Columns.Add("IdentifierPattern", typeof(string));
      tbl.Columns.Add("IdentifierCase", typeof(int));
................................................................................

      tbl.BeginLoadData();

      // TODO: Fixup the regular expressions to support only the SQLite stuff, they were originally cloned
      // from JET's DataSourceInformation return result.
      row = tbl.NewRow();
      row.ItemArray = new object[] {
        DBNull.Value,
        "SQLite",
        _sql.Version,
        _sql.Version,
        3,
        @"[^ ][^\.!`\[\]]*",
        1,


        DBNull.Value,
        "?",
        "?",
        0,
        DBNull.Value,
        @"`(([^`]|``)*)`",
        1,
        DBNull.Value,
        DBNull.Value,
        DBNull.Value
      };
      tbl.Rows.Add(row);

      tbl.AcceptChanges();
      tbl.EndLoadData();

      return tbl;
................................................................................
    /// <param name="strColumn">The column to retrieve schema information for, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Columns(string strCatalog, string strTable, string strColumn)
    {
      DataTable tbl = new DataTable("Columns");
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("COLUMN_NAME", typeof(string));
      tbl.Columns.Add("COLUMN_GUID", typeof(Guid));
      tbl.Columns.Add("COLUMN_PROPID", typeof(long));
      tbl.Columns.Add("ORDINAL_POSITION", typeof(long));
      tbl.Columns.Add("COLUMN_HASDEFAULT", typeof(bool));
      tbl.Columns.Add("COLUMN_DEFAULT", typeof(string));
      tbl.Columns.Add("COLUMN_FLAGS", typeof(long));
      tbl.Columns.Add("IS_NULLABLE", typeof(bool));
      tbl.Columns.Add("DATA_TYPE", typeof(int));
      tbl.Columns.Add("TYPE_GUID", typeof(Guid));
      tbl.Columns.Add("CHARACTER_MAXIMUM_LENGTH", typeof(long));
      tbl.Columns.Add("CHARACTER_OCTET_LENGTH", typeof(long));
      tbl.Columns.Add("NUMERIC_PRECISION", typeof(int));
      tbl.Columns.Add("NUMERIC_SCALE", typeof(short));
      tbl.Columns.Add("DATETIME_PRECISION", typeof(long));
      tbl.Columns.Add("CHARACTER_SET_CATALOG", typeof(string));
      tbl.Columns.Add("CHARACTER_SET_SCHEMA", typeof(string));
      tbl.Columns.Add("CHARACTER_SET_NAME", typeof(string));
      tbl.Columns.Add("COLLATION_CATALOG", typeof(string));
      tbl.Columns.Add("COLLATION_SCHEMA", typeof(string));
      tbl.Columns.Add("COLLATION_NAME", typeof(string));
................................................................................
      tbl.Columns.Add("DOMAIN_NAME", typeof(string));
      tbl.Columns.Add("DESCRIPTION", typeof(string));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(System.Globalization.CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[{1}]", strCatalog, strTable), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader(CommandBehavior.SchemaOnly))
        {
          using (DataTable tblSchema = rd.GetSchemaTable())
          {
            foreach (DataRow schemaRow in tblSchema.Rows)
            {
              if (String.Compare(schemaRow[SchemaTableColumn.ColumnName].ToString(), strColumn, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strColumn == null)

              {
                row = tbl.NewRow();

                row["TABLE_NAME"] = strTable;
                row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.ColumnName];
                row["TABLE_CATALOG"] = schemaRow[SchemaTableOptionalColumn.BaseCatalogName];
                row["ORDINAL_POSITION"] = schemaRow[SchemaTableColumn.ColumnOrdinal];
                row["COLUMN_HASDEFAULT"] = (schemaRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value);
                row["COLUMN_DEFAULT"] = schemaRow[SchemaTableOptionalColumn.DefaultValue];
                row["IS_NULLABLE"] = schemaRow[SchemaTableColumn.AllowDBNull];
                row["DATA_TYPE"] = schemaRow[SchemaTableColumn.ProviderType];
                row["CHARACTER_MAXIMUM_LENGTH"] = schemaRow[SchemaTableColumn.ColumnSize];


                tbl.Rows.Add(row);
              }
            }
          }
        }
      }
................................................................................
    /// <param name="strTable">The table to retrieve index information for, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Indexes(string strCatalog, string strIndex, string strTable)
    {
      DataTable tbl = new DataTable("Indexes");
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("INDEX_CATALOG", typeof(string));
      tbl.Columns.Add("INDEX_SCHEMA", typeof(string));
      tbl.Columns.Add("INDEX_NAME", typeof(string));
      tbl.Columns.Add("PRIMARY_KEY", typeof(bool));
................................................................................
      tbl.Columns.Add("FILTER_CONDITION", typeof(string));
      tbl.Columns.Add("INTEGRATED", typeof(bool));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(System.Globalization.CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] = 'index'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (String.Compare(rd.GetString(1), strIndex, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strIndex == null)

            {
              if (String.Compare(rd.GetString(2), strTable, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strTable == null)

              {
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["INDEX_NAME"] = rd.GetString(1);

                tbl.Rows.Add(row);
              }
            }
................................................................................
    /// <returns>DataTable</returns>
    private DataTable Schema_Tables(string strCatalog, string strTable, string strType)
    {
      DataTable tbl = new DataTable("Tables");
      DataRow row;
      string strItem;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("TABLE_TYPE", typeof(string));
      tbl.Columns.Add("TABLE_GUID", typeof(Guid));
      tbl.Columns.Add("DESCRIPTION", typeof(string));
      tbl.Columns.Add("TABLE_PROPID", typeof(long));
      tbl.Columns.Add("DATE_CREATED", typeof(DateTime));
      tbl.Columns.Add("DATE_MODIFIED", typeof(DateTime));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(System.Globalization.CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] NOT LIKE 'index'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            strItem = rd.GetString(0).ToUpper(System.Globalization.CultureInfo.CurrentCulture);
            if (rd.GetString(2).ToUpper(System.Globalization.CultureInfo.CurrentCulture).IndexOf("SQLITE_") == 0)
              strItem = "SYSTEM TABLE";

            if (String.Compare(strItem, strType, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strType == null)

            {
              if (String.Compare(rd.GetString(2), strTable, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strTable == null)

              {
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["TABLE_TYPE"] = strItem;

                tbl.Rows.Add(row);
              }
            }
................................................................................
    private DataTable Schema_Views(string strCatalog, string strView)
    {
      DataTable tbl = new DataTable("Views");
      DataRow row;
      string strItem;
      int nPos;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("VIEW_DEFINITION", typeof(string));
      tbl.Columns.Add("CHECK_OPTION", typeof(bool));
      tbl.Columns.Add("IS_UPDATEABLE", typeof(bool));
      tbl.Columns.Add("DESCRIPTION", typeof(string));
      tbl.Columns.Add("DATE_CREATED", typeof(DateTime));
      tbl.Columns.Add("DATE_MODIFIED", typeof(DateTime));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(System.Globalization.CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] LIKE 'view'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (String.Compare(rd.GetString(1), strView, true, System.Globalization.CultureInfo.CurrentCulture) == 0 || strView == null)

            {
              strItem = rd.GetString(4);
              nPos = Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(strItem, " AS ");
              if (nPos > -1)
              {
                strItem = strItem.Substring(nPos + 4);
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["IS_UPDATEABLE"] = false;
                row["VIEW_DEFINITION"] = strItem;

                tbl.Rows.Add(row);
              }
            }
          }
        }
................................................................................
    /// <param name="strCatalog">The catalog to retrieve, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Catalogs(string strCatalog)
    {
      DataTable tbl = new DataTable("Catalogs");
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add("CATALOG_NAME", typeof(string));
      tbl.Columns.Add("DESCRIPTION", typeof(string));

      tbl.BeginLoadData();

      using (SQLiteCommand cmd = new SQLiteCommand("PRAGMA database_list", this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (strCatalog == null || String.Compare(rd.GetString(1), strCatalog, true, System.Globalization.CultureInfo.CurrentCulture) == 0)

            {
              row = tbl.NewRow();

              row["CATALOG_NAME"] = rd.GetString(1);

              tbl.Rows.Add(row);
            }
          }
        }
      }

      tbl.AcceptChanges();
      tbl.EndLoadData();

      return tbl;
    }
  }





}





























































































































































































































































>




|







 







>
>
>
>







 







|
|







 







|



>
>
|
>



|



>
>
|
>







 







|







 







|


>
>
>
>
>


<
|
>


<
>

<
>

|
>
>






|
|
|
|







 







>
>
|
>







 







|





>
>
>
>











|











|







 







>
>
>
>
>
>
>
>







 







|







 







|




<
<
>
>
|



|
|
|
|
|
|







 







|






|




|

|
|

|







 







|







|
>





|




|

>







 







|







 







|





|
>

|
>


>







 







|




<
<
<
<
<





|





|
|
|

|
>

|
>


>







 







|





|








|





|
>







>


|







 







|











|
>


>

>











|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
...
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463

464
465
466
467

468
469

470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
...
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
...
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
...
689
690
691
692
693
694
695
696
697
698
699
700


701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
...
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
...
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
...
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
...
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
...
884
885
886
887
888
889
890
891
892
893
894
895





896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
...
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
....
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;
  using System.Globalization;

  /// <summary>
  /// The I/O file cache flushing behavior for the connection
  /// </summary>
  public enum SynchronizationModes
  {
    /// <summary>
    /// Normal file flushing at critical sections of the code
    /// </summary>
    Normal = 0,
    /// <summary>
    /// Full file flushing after every write operation
................................................................................
    /// The base SQLite object to interop with
    /// </summary>
    internal SQLiteBase          _sql;
    /// <summary>
    /// Commands associated with this connection
    /// </summary>
    internal List<SQLiteCommand> _commandList;
    /// <summary>
    /// The database filename minus path and extension
    /// </summary>
    private string _dataSource;

    /// <event/>
    /// <summary>
    /// This event is raised whenever the database is opened or closed.
    /// </summary>
    public override event StateChangeEventHandler StateChange;

................................................................................

        // Reattach all attached databases from the existing connection
        using (DataTable tbl = cnn.GetSchema("Catalogs"))
        {
          foreach (DataRow row in tbl.Rows)
          {
            str = row[0].ToString();
            if (String.Compare(str, "main", true, CultureInfo.InvariantCulture) != 0
              && String.Compare(str, "temp", true, CultureInfo.InvariantCulture) != 0)
            {
              _sql.Execute(String.Format(System.Globalization.CultureInfo.InvariantCulture, "ATTACH DATABASE '{0}' AS [{1}]", row[1], row[0]));
            }
          }
        }
      }
    }
................................................................................
    /// <returns>Returns an instantiated SQLiteCommand object already assigned to this connection.</returns>
    protected override DbCommand CreateDbCommand()
    {
      return new SQLiteCommand(this);
    }

    /// <summary>
    /// Returns the filename without extension or path
    /// </summary>
    public override string DataSource
    {
      get 
      {
        return _dataSource;
      }
    }

    /// <summary>
    /// Returns an empty string
    /// </summary>
    public override string Database
    {
      get
      {
        return "main";
      }
    }

    /// <summary>
    /// Parses the connection string into component parts
    /// </summary>
    /// <returns>An array of key-value pairs representing each parameter of the connection string</returns>
    internal KeyValuePair<string, string>[] ParseConnectionString()
................................................................................
    /// <param name="defValue">The default value to return if the key is not found</param>
    /// <returns>The value corresponding to the specified key, or the default value if not found.</returns>
    static internal string FindKey(KeyValuePair<string, string>[] opts, string key, string defValue)
    {
      int x = opts.Length;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(opts[n].Key, key, true, CultureInfo.InvariantCulture) == 0)
        {
          return opts[n].Value;
        }
      }
      return defValue;
    }

................................................................................
      if (_connectionState != ConnectionState.Closed)
        throw new InvalidOperationException();

      Close();

      KeyValuePair<string, string>[] opts = ParseConnectionString();

      if (Convert.ToInt32(FindKey(opts, "Version", "3"), CultureInfo.InvariantCulture) != 3)
        throw new NotSupportedException("Only SQLite Version 3 is supported at this time");

      string strFile = FindKey(opts, "Data Source", "");

      if (String.IsNullOrEmpty(strFile))
        throw new ArgumentException("Data Source cannot be empty.  Use :MEMORY: to open an in-memory database");

      try
      {

        bool bUTF16 = (Convert.ToBoolean(FindKey(opts, "UseUTF16Encoding", "False"), CultureInfo.InvariantCulture) == true);
        SQLiteDateFormats dateFormat = String.Compare(FindKey(opts, "DateTimeFormat", "ISO8601"), "ticks", true, CultureInfo.CurrentCulture) == 0 ? SQLiteDateFormats.Ticks : SQLiteDateFormats.ISO8601;

        if (bUTF16)

          _sql = new SQLite3_UTF16(dateFormat);
        else

          _sql = new SQLite3(dateFormat);

          _sql.Open(strFile);

        _dataSource = System.IO.Path.GetFileNameWithoutExtension(strFile);

        if (bUTF16 == true)
          _sql.Execute("PRAGMA encoding = 'UTF-16'");
        else
          _sql.Execute("PRAGMA encoding = 'UTF-8'");

        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Synchronous={0}", FindKey(opts, "Synchronous", "Normal")));
        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Cache_Size={0}", FindKey(opts, "Cache Size", "2000")));
        if (String.Compare(":MEMORY:", strFile, true, CultureInfo.CurrentCulture) == 0)
          _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Page_Size={0}", FindKey(opts, "Page Size", "1024")));
      }
      catch (SQLiteException)
      {
        OnStateChange(ConnectionState.Broken);
        throw;
      }
      OnStateChange(ConnectionState.Open);
................................................................................
    }

    /// <summary>
    /// Returns the state of the connection.
    /// </summary>
    public override ConnectionState State
    {
      get
      {
        return _connectionState;
      }
    }

    ///<overloads>
    /// The following commands are used to extract schema information out of the database.  Valid schema types are:
    /// <list type="bullet">
    /// <item>
    /// <description>MetaDataCollections</description>
................................................................................
        throw new InvalidOperationException();

      string[] parms = new string[5];

      restrictionValues.CopyTo(parms, 0);

      if (restrictionValues == null) restrictionValues = new string[0];
      switch (collectionName.ToUpper(CultureInfo.CurrentCulture))
      {
        case "METADATACOLLECTIONS":
          return Schema_MetaDataCollections();
        case "DATASOURCEINFORMATION":
          return Schema_DataSourceInformation();
        //case "RESERVEDWORDS":
        //  return Schema_ReservedWords();
        case "DATATYPES":
          return Schema_DataTypes();
        case "COLUMNS":
          return Schema_Columns(parms[0], parms[2], parms[3]);
        case "INDEXES":
          return Schema_Indexes(parms[0], parms[2], parms[4]);
        case "TABLES":
          return Schema_Tables(parms[0], parms[2], parms[3]);
        case "VIEWS":
          return Schema_Views(parms[0], parms[2]);
        case "CATALOGS":
          return Schema_Catalogs(parms[0]);
      }
      throw new NotSupportedException();
    }

    /// <summary>
    /// Builds a MetaDataCollections schema datatable
    /// </summary>
    /// <returns>DataTable</returns>
    private static DataTable Schema_MetaDataCollections()
    {
      DataTable tbl = new DataTable("MetaDataCollections");
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("CollectionName", typeof(string));
      tbl.Columns.Add("NumberOfRestrictions", typeof(int));
      tbl.Columns.Add("NumberOfIdentifierParts", typeof(int));

      tbl.BeginLoadData();

      row = tbl.NewRow();
................................................................................
      row.ItemArray = new object[] { "MetaDataCollections", 0, 0 };
      tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "DataSourceInformation", 0, 0 };
      tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "DataTypes", 0, 0 };
      tbl.Rows.Add(row);

      //row = tbl.NewRow();
      //row.ItemArray = new object[] { "ReservedWords", 0, 0 };
      //tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "Catalogs", 1, 1 };
      tbl.Rows.Add(row);

      row = tbl.NewRow();
      row.ItemArray = new object[] { "Columns", 4, 4 };
      tbl.Rows.Add(row);
................................................................................
    /// </summary>
    /// <returns>DataTable</returns>
    private DataTable Schema_DataSourceInformation()
    {
      DataTable tbl = new DataTable("DataSourceInformation");
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("CompositeIdentifierSeparatorPattern", typeof(string));
      tbl.Columns.Add("DataSourceProductName", typeof(string));
      tbl.Columns.Add("DataSourceProductVersion", typeof(string));
      tbl.Columns.Add("DataSourceProductVersionNormalized", typeof(string));
      tbl.Columns.Add("GroupByBehavior", typeof(int));
      tbl.Columns.Add("IdentifierPattern", typeof(string));
      tbl.Columns.Add("IdentifierCase", typeof(int));
................................................................................

      tbl.BeginLoadData();

      // TODO: Fixup the regular expressions to support only the SQLite stuff, they were originally cloned
      // from JET's DataSourceInformation return result.
      row = tbl.NewRow();
      row.ItemArray = new object[] {
        null,
        "SQLite",
        _sql.Version,
        _sql.Version,
        3,


        null,
        2,
        false,
        "?",
        "?",
        0,
        null,
        @"(([^\[]|\]\])*)",
        2,
        ";",
        @"'(([^']|'')*)'",
        null
      };
      tbl.Rows.Add(row);

      tbl.AcceptChanges();
      tbl.EndLoadData();

      return tbl;
................................................................................
    /// <param name="strColumn">The column to retrieve schema information for, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Columns(string strCatalog, string strTable, string strColumn)
    {
      DataTable tbl = new DataTable("Columns");
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("COLUMN_NAME", typeof(string));
      tbl.Columns.Add("COLUMN_GUID", typeof(Guid));
      tbl.Columns.Add("COLUMN_PROPID", typeof(long));
      tbl.Columns.Add("ORDINAL_POSITION", typeof(int));
      tbl.Columns.Add("COLUMN_HASDEFAULT", typeof(bool));
      tbl.Columns.Add("COLUMN_DEFAULT", typeof(string));
      tbl.Columns.Add("COLUMN_FLAGS", typeof(long));
      tbl.Columns.Add("IS_NULLABLE", typeof(bool));
      tbl.Columns.Add("DATA_TYPE", typeof(string));
      tbl.Columns.Add("TYPE_GUID", typeof(Guid));
      tbl.Columns.Add("CHARACTER_MAXIMUM_LENGTH", typeof(int));
      tbl.Columns.Add("CHARACTER_OCTET_LENGTH", typeof(int));
      tbl.Columns.Add("NUMERIC_PRECISION", typeof(int));
      tbl.Columns.Add("NUMERIC_SCALE", typeof(int));
      tbl.Columns.Add("DATETIME_PRECISION", typeof(long));
      tbl.Columns.Add("CHARACTER_SET_CATALOG", typeof(string));
      tbl.Columns.Add("CHARACTER_SET_SCHEMA", typeof(string));
      tbl.Columns.Add("CHARACTER_SET_NAME", typeof(string));
      tbl.Columns.Add("COLLATION_CATALOG", typeof(string));
      tbl.Columns.Add("COLLATION_SCHEMA", typeof(string));
      tbl.Columns.Add("COLLATION_NAME", typeof(string));
................................................................................
      tbl.Columns.Add("DOMAIN_NAME", typeof(string));
      tbl.Columns.Add("DESCRIPTION", typeof(string));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[{1}]", strCatalog, strTable), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader(CommandBehavior.SchemaOnly))
        {
          using (DataTable tblSchema = rd.GetSchemaTable())
          {
            foreach (DataRow schemaRow in tblSchema.Rows)
            {
              if (String.Compare(schemaRow[SchemaTableColumn.ColumnName].ToString(), strColumn, true, CultureInfo.CurrentCulture) == 0
                || strColumn == null)
              {
                row = tbl.NewRow();

                row["TABLE_NAME"] = strTable;
                row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.ColumnName];
                row["TABLE_CATALOG"] = strCatalog;
                row["ORDINAL_POSITION"] = schemaRow[SchemaTableColumn.ColumnOrdinal];
                row["COLUMN_HASDEFAULT"] = (schemaRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value);
                row["COLUMN_DEFAULT"] = schemaRow[SchemaTableOptionalColumn.DefaultValue];
                row["IS_NULLABLE"] = schemaRow[SchemaTableColumn.AllowDBNull];
                row["DATA_TYPE"] = SQLiteConvert.DbTypeToType((DbType)schemaRow[SchemaTableColumn.ProviderType]).ToString();
                row["CHARACTER_MAXIMUM_LENGTH"] = schemaRow[SchemaTableColumn.ColumnSize];
                row["TABLE_SCHEMA"] = schemaRow[SchemaTableColumn.BaseSchemaName];

                tbl.Rows.Add(row);
              }
            }
          }
        }
      }
................................................................................
    /// <param name="strTable">The table to retrieve index information for, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Indexes(string strCatalog, string strIndex, string strTable)
    {
      DataTable tbl = new DataTable("Indexes");
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("INDEX_CATALOG", typeof(string));
      tbl.Columns.Add("INDEX_SCHEMA", typeof(string));
      tbl.Columns.Add("INDEX_NAME", typeof(string));
      tbl.Columns.Add("PRIMARY_KEY", typeof(bool));
................................................................................
      tbl.Columns.Add("FILTER_CONDITION", typeof(string));
      tbl.Columns.Add("INTEGRATED", typeof(bool));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] = 'index'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (String.Compare(rd.GetString(1), strIndex, true, CultureInfo.CurrentCulture) == 0
            || strIndex == null)
            {
              if (String.Compare(rd.GetString(2), strTable, true, CultureInfo.CurrentCulture) == 0 
              || strTable == null)
              {
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["INDEX_NAME"] = rd.GetString(1);

                tbl.Rows.Add(row);
              }
            }
................................................................................
    /// <returns>DataTable</returns>
    private DataTable Schema_Tables(string strCatalog, string strTable, string strType)
    {
      DataTable tbl = new DataTable("Tables");
      DataRow row;
      string strItem;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("TABLE_TYPE", typeof(string));






      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] NOT LIKE 'index'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            strItem = rd.GetString(0).ToUpper(CultureInfo.CurrentCulture);
            if (rd.GetString(2).ToUpper(CultureInfo.CurrentCulture).IndexOf("SQLITE_") == 0)
              strItem = "SYSTEM_TABLE";

            if (String.Compare(strType, strItem, true, CultureInfo.CurrentCulture) == 0
              || strType == null)
            {
              if (String.Compare(rd.GetString(2), strTable, true, CultureInfo.CurrentCulture) == 0
                || strTable == null)
              {
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["TABLE_TYPE"] = strItem;

                tbl.Rows.Add(row);
              }
            }
................................................................................
    private DataTable Schema_Views(string strCatalog, string strView)
    {
      DataTable tbl = new DataTable("Views");
      DataRow row;
      string strItem;
      int nPos;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("TABLE_CATALOG", typeof(string));
      tbl.Columns.Add("TABLE_SCHEMA", typeof(string));
      tbl.Columns.Add("TABLE_NAME", typeof(string));
      tbl.Columns.Add("VIEW_DEFINITION", typeof(string));
      tbl.Columns.Add("CHECK_OPTION", typeof(bool));
      tbl.Columns.Add("IS_UPDATABLE", typeof(bool));
      tbl.Columns.Add("DESCRIPTION", typeof(string));
      tbl.Columns.Add("DATE_CREATED", typeof(DateTime));
      tbl.Columns.Add("DATE_MODIFIED", typeof(DateTime));

      tbl.BeginLoadData();

      if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main";

      using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] LIKE 'view'", strCatalog), this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (String.Compare(rd.GetString(1), strView, true, CultureInfo.CurrentCulture) == 0
              || strView == null)
            {
              strItem = rd.GetString(4);
              nPos = Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(strItem, " AS ");
              if (nPos > -1)
              {
                strItem = strItem.Substring(nPos + 4);
                row = tbl.NewRow();

                row["TABLE_CATALOG"] = strCatalog;
                row["TABLE_NAME"] = rd.GetString(2);
                row["IS_UPDATABLE"] = false;
                row["VIEW_DEFINITION"] = strItem;

                tbl.Rows.Add(row);
              }
            }
          }
        }
................................................................................
    /// <param name="strCatalog">The catalog to retrieve, can be null</param>
    /// <returns>DataTable</returns>
    private DataTable Schema_Catalogs(string strCatalog)
    {
      DataTable tbl = new DataTable("Catalogs");
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("CATALOG_NAME", typeof(string));
      tbl.Columns.Add("DESCRIPTION", typeof(string));

      tbl.BeginLoadData();

      using (SQLiteCommand cmd = new SQLiteCommand("PRAGMA database_list", this))
      {
        using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader())
        {
          while (rd.Read())
          {
            if (String.Compare(rd.GetString(1), strCatalog, true, CultureInfo.CurrentCulture) == 0
              || strCatalog == null)
            {
              row = tbl.NewRow();

              row["CATALOG_NAME"] = rd.GetString(1);

              tbl.Rows.Add(row);
            }
          }
        }
      }

      tbl.AcceptChanges();
      tbl.EndLoadData();

      return tbl;
    }

    //private DataTable Schema_ReservedWords()
    //{
    //  DataTable tbl = new DataTable("ReservedWords");
    //  DataRow row;
    //  const string reservedWords = "LEFT INNER OUTER JOIN SELECT INSERT UPDATE LIKE ORDER BY INTEGER PRIMARY KEY ON AS IN BETWEEN";

    //  tbl.Locale = CultureInfo.InvariantCulture;
    //  tbl.Columns.Add("ReservedWord", typeof(String));

    //  tbl.BeginLoadData();

    //  string[] ar = reservedWords.Split(' ');

    //  foreach (string s in ar)
    //  {
    //    row = tbl.NewRow();
    //    row[0] = s;
    //    tbl.Rows.Add(row);
    //  }

    //  tbl.AcceptChanges();
    //  tbl.EndLoadData();

    //  return tbl;
    //}

    private DataTable Schema_DataTypes()
    {
      DataTable tbl = new DataTable("DataTypes");

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add("TypeName", typeof(String));
      tbl.Columns.Add("ProviderDbType", typeof(int));
      tbl.Columns.Add("ColumnSize", typeof(long));
      tbl.Columns.Add("CreateFormat", typeof(String));
      tbl.Columns.Add("CreateParameters", typeof(String));
      tbl.Columns.Add("DataType", typeof(String));
      tbl.Columns.Add("IsAutoIncrementable", typeof(bool));
      tbl.Columns.Add("IsBestMatch", typeof(bool));
      tbl.Columns.Add("IsCaseSensitive", typeof(bool));
      tbl.Columns.Add("IsFixedLength", typeof(bool));
      tbl.Columns.Add("IsFixedPrecisionScale", typeof(bool));
      tbl.Columns.Add("IsLong", typeof(bool));
      tbl.Columns.Add("IsNullable", typeof(bool));
      tbl.Columns.Add("IsSearchable", typeof(bool));
      tbl.Columns.Add("IsSearchableWithLike", typeof(bool));
      tbl.Columns.Add("IsLiteralSupported", typeof(bool));
      tbl.Columns.Add("LiteralPrefix", typeof(String));
      tbl.Columns.Add("LiteralSuffix", typeof(String));
      tbl.Columns.Add("IsUnsigned", typeof(bool));
      tbl.Columns.Add("MaximumScale", typeof(short));
      tbl.Columns.Add("MinimumScale", typeof(short));
      tbl.Columns.Add("IsConcurrencyType", typeof(bool));

      tbl.BeginLoadData();
      string dataTypesXml = @"<?xml version=""1.0"" standalone=""yes""?>
<DocumentElement>
  <DataTypes>
    <TypeName>System.Int16</TypeName>
    <ProviderDbType>10</ProviderDbType>
    <ColumnSize>5</ColumnSize>
    <DataType>System.Int16</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Int32</TypeName>
    <ProviderDbType>8</ProviderDbType>
    <ColumnSize>10</ColumnSize>
    <DataType>System.Int32</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Single</TypeName>
    <ProviderDbType>15</ProviderDbType>
    <ColumnSize>7</ColumnSize>
    <DataType>System.Single</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Double</TypeName>
    <ProviderDbType>8</ProviderDbType>
    <ColumnSize>6</ColumnSize>
    <DataType>System.Double</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Decimal</TypeName>
    <ProviderDbType>7</ProviderDbType>
    <ColumnSize>19</ColumnSize>
    <DataType>System.Decimal</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Boolean</TypeName>
    <ProviderDbType>3</ProviderDbType>
    <ColumnSize>1</ColumnSize>
    <DataType>System.Boolean</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Byte</TypeName>
    <ProviderDbType>2</ProviderDbType>
    <ColumnSize>3</ColumnSize>
    <DataType>System.Byte</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>true</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Int64</TypeName>
    <ProviderDbType>12</ProviderDbType>
    <ColumnSize>19</ColumnSize>
    <DataType>System.Int64</DataType>
    <IsAutoIncrementable>true</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <IsUnsigned>false</IsUnsigned>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Byte[]</TypeName>
    <ProviderDbType>1</ProviderDbType>
    <ColumnSize>2147483647</ColumnSize>
    <DataType>System.Byte[]</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>false</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>true</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>false</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
  </DataTypes>
  <DataTypes>
    <TypeName>System.String</TypeName>
    <ProviderDbType>16</ProviderDbType>
    <ColumnSize>2147483647</ColumnSize>
    <CreateParameters>max length</CreateParameters>
    <DataType>System.String</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>false</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>true</IsSearchableWithLike>
    <LiteralPrefix>'</LiteralPrefix>
    <LiteralSuffix>'</LiteralSuffix>
  </DataTypes>
  <DataTypes>
    <TypeName>System.DateTime</TypeName>
    <ProviderDbType>6</ProviderDbType>
    <ColumnSize>23</ColumnSize>
    <DataType>System.DateTime</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>true</IsSearchableWithLike>
    <LiteralPrefix>'</LiteralPrefix>
    <LiteralSuffix>'</LiteralSuffix>
  </DataTypes>
  <DataTypes>
    <TypeName>System.Guid</TypeName>
    <ProviderDbType>4</ProviderDbType>
    <ColumnSize>16</ColumnSize>
    <DataType>System.Guid</DataType>
    <IsAutoIncrementable>false</IsAutoIncrementable>
    <IsCaseSensitive>false</IsCaseSensitive>
    <IsFixedLength>true</IsFixedLength>
    <IsFixedPrecisionScale>false</IsFixedPrecisionScale>
    <IsLong>false</IsLong>
    <IsNullable>true</IsNullable>
    <IsSearchable>true</IsSearchable>
    <IsSearchableWithLike>false</IsSearchableWithLike>
    <LiteralPrefix>'</LiteralPrefix>
    <LiteralSuffix>'</LiteralSuffix>
  </DataTypes>
</DocumentElement>";

      IO.StringReader stringReader = new System.IO.StringReader(dataTypesXml);
      tbl.ReadXml(stringReader);
      stringReader.Close();

      tbl.AcceptChanges();
      tbl.EndLoadData();

      return tbl;
    }
  }
}

Changes to System.Data.SQLite/SQLiteConnectionStringBuilder.cs.

5
6
7
8
9
10
11


12
13


14
15
16

17
18





19
20
21
22
23
24
25
..
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75


76
77
78
79


80
81
82
83
84
85
86
..
87
88
89
90
91
92
93



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136


137
138
139
140


141
142
143
144
145
146
147
148
149
150
151



152
153
154
155

156
157
158
159
160
161
162
163
164
165
166



167
168
169
170

171
172
173
174
175
176
177
178
179
180
181
182


183
184
185
186
187
188
189

190

191
192
193





















194
195
196


197
198
199
200
201
202
203


204
205

206
207
208
209
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Data.Common;



#if !PLATFORM_COMPACTFRAMEWORK


  /// <summary>
  /// SQLite implementation of DbConnectionStringBuilder.
  /// </summary>

  public sealed class SQLiteConnectionStringBuilder : DbConnectionStringBuilder
  {





    /// <overloads>
    /// Constructs a new instance of the class
    /// </overloads>
    /// <summary>
    /// Default constructor
    /// </summary>
    public SQLiteConnectionStringBuilder()
................................................................................

    /// <summary>
    /// Private initializer, which assigns the connection string and resets the builder
    /// </summary>
    /// <param name="cnnString">The connection string to assign</param>
    private void Initialize(string cnnString)
    {
      ConnectionString = cnnString;
      Reset();
    }


    /// <summary>
    /// Resets the builder to the default settings
    /// </summary>
    internal void Reset()
    {
      if (this.ContainsKey("Version") == false)
        Version = 3;

      if (ContainsKey("UseUTF16Encoding") == false)
        UseUTF16Encoding = false;

      if (ContainsKey("Cache Size") == false)
        CacheSize = 2000;

      if (ContainsKey("Synchronous") == false)
        SyncMode = SyncMode.Normal;

      if (ContainsKey("DateTimeFormat") == false)
        DateTimeFormat = DateTimeFormat.ISO8601;

      if (ContainsKey("Page Size") == false)
        PageSize = 4096;
    }

    /// <summary>
    /// Gets/Sets the default version of the SQLite engine to instantiate.  Currently the only valid value is 3, indicating version 3 of the sqlite library.
    /// </summary>


    public int Version
    {
      get
      {


        return Convert.ToInt32(this["Version"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        if (value != 3)
          throw new NotSupportedException();

................................................................................
        this["Version"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the synchronous mode of the connection string.  Default is "Normal".
    /// </summary>



    public SyncMode SyncMode
    {
      get
      {
        string s = this["Synchronous"].ToString().ToUpper(System.Globalization.CultureInfo.CurrentCulture);
        switch (s)
        {
          case "FULL":
            return SyncMode.Full;
          case "OFF":
            return SyncMode.Off;
          default:
            return SyncMode.Normal;
        }
      }
      set
      {
        string s = "Normal";
        if (value == SyncMode.Full) s = "Full";
        else if (value == SyncMode.Off) s = "Off";

        this["Synchronous"] = s;
      }
    }

    /// <summary>
    /// Gets/Sets the encoding for the connection string.  The default is "False" which indicates UTF-8 encoding.
    /// </summary>


    public bool UseUTF16Encoding
    {
      get
      {
        return (String.Compare(this["UseUTF16Encoding"].ToString(), "True", true, System.Globalization.CultureInfo.InvariantCulture) == 0);
      }
      set
      {
        this["UseUTF16Encoding"] = ((value == true) ? "True" : "False");
      }
    }

    /// <summary>
    /// Gets/Sets the filename to open on the connection string.
    /// </summary>


    public string DataSource
    {
      get
      {


        return this["Data Source"].ToString();
      }
      set
      {
        this["Data Source"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the page size for the connection.
    /// </summary>



    public int PageSize
    {
      get
      {

        return Convert.ToInt32(this["Page Size"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        this["Page Size"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the cache size for the connection.
    /// </summary>



    public int CacheSize
    {
      get
      {

        return Convert.ToInt32(this["Cache Size"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        this["Cache Size"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the datetime format for the connection.
    /// </summary>
    public DateTimeFormat DateTimeFormat


    {
      get
      {
        switch (this["DateTimeFormat"].ToString().ToUpper(System.Globalization.CultureInfo.InvariantCulture))
        {
          case "TICKS":
            return DateTimeFormat.Ticks;

          default:

            return DateTimeFormat.ISO8601;
        }
      }





















      set
      {
        switch (value)


        {
          case DateTimeFormat.Ticks:
            this["DateTimeFormat"] = "Ticks";
            break;
          case DateTimeFormat.ISO8601:
            this["DateTimeFormat"] = "ISO8601";
            break;


        }
      }

    }
  }
#endif
}







>
>
|

>
>



>


>
>
>
>
>







 







|
|
|
<
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





>
>




>
>







 







>
>
>
|



|
<
<
<
<
<
<
<
<
<



<
<
<
<
|






>
>




|



|






>
>




>
>











>
>
>




>











>
>
>




>











|
>
>



|
|
|
<
>
|
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

<
>
>

<
<
<
<
<
<
>
>


>




5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
48
49
50
51
52
53
54
55
56
57

58
59





















60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94









95
96
97




98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

217
218
219






220
221
222
223
224
225
226
227
228
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Data.Common;
  using System.ComponentModel;
  using System.Collections;
  
#if !PLATFORM_COMPACTFRAMEWORK
  using System.ComponentModel.Design;

  /// <summary>
  /// SQLite implementation of DbConnectionStringBuilder.
  /// </summary>
  [DefaultProperty("DataSource")]
  public sealed class SQLiteConnectionStringBuilder : DbConnectionStringBuilder
  {
    /// <summary>
    /// Properties of this class
    /// </summary>
    private Hashtable _properties;

    /// <overloads>
    /// Constructs a new instance of the class
    /// </overloads>
    /// <summary>
    /// Default constructor
    /// </summary>
    public SQLiteConnectionStringBuilder()
................................................................................

    /// <summary>
    /// Private initializer, which assigns the connection string and resets the builder
    /// </summary>
    /// <param name="cnnString">The connection string to assign</param>
    private void Initialize(string cnnString)
    {
      _properties = new Hashtable();
      base.GetProperties(_properties);


      if (String.IsNullOrEmpty(cnnString) == false)
        ConnectionString = cnnString;





















    }

    /// <summary>
    /// Gets/Sets the default version of the SQLite engine to instantiate.  Currently the only valid value is 3, indicating version 3 of the sqlite library.
    /// </summary>
    [Browsable(true)]
    [DefaultValue(3)]
    public int Version
    {
      get
      {
        if (ContainsKey("Version") == false) return 3;

        return Convert.ToInt32(this["Version"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        if (value != 3)
          throw new NotSupportedException();

................................................................................
        this["Version"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the synchronous mode of the connection string.  Default is "Normal".
    /// </summary>
    [DisplayName("Synchronous")]
    [Browsable(true)]
    [DefaultValue(SynchronizationModes.Normal)]
    public SynchronizationModes SyncMode
    {
      get
      {
        return (SynchronizationModes)TypeDescriptor.GetConverter(typeof(SynchronizationModes)).ConvertFrom(this["Synchronous"]);









      }
      set
      {




        this["Synchronous"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the encoding for the connection string.  The default is "False" which indicates UTF-8 encoding.
    /// </summary>
    [Browsable(true)]
    [DefaultValue(false)]
    public bool UseUTF16Encoding
    {
      get
      {
        return Convert.ToBoolean(this["UseUTF16Encoding"]);
      }
      set
      {
        this["UseUTF16Encoding"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the filename to open on the connection string.
    /// </summary>
    [DisplayName("Data Source")]
    [Browsable(true)]
    public string DataSource
    {
      get
      {
        if (ContainsKey("Data Source") == false) return "";

        return this["Data Source"].ToString();
      }
      set
      {
        this["Data Source"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the page size for the connection.
    /// </summary>
    [DisplayName("Page Size")]
    [Browsable(true)]
    [DefaultValue(1024)]
    public int PageSize
    {
      get
      {
        if (ContainsKey("Page Size") == false) return 1024;
        return Convert.ToInt32(this["Page Size"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        this["Page Size"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the cache size for the connection.
    /// </summary>
    [DisplayName("Cache Size")]
    [Browsable(true)]
    [DefaultValue(2000)]
    public int CacheSize
    {
      get
      {
        if (ContainsKey("Cache Size") == false) return 2000;
        return Convert.ToInt32(this["Cache Size"], System.Globalization.CultureInfo.InvariantCulture);
      }
      set
      {
        this["Cache Size"] = value;
      }
    }

    /// <summary>
    /// Gets/Sets the datetime format for the connection.
    /// </summary>
    [Browsable(true)]
    [DefaultValue(SQLiteDateFormats.ISO8601)]
    public SQLiteDateFormats DateTimeFormat
    {
      get
      {
        if (ContainsKey("DateTimeFormat") == false) return SQLiteDateFormats.ISO8601;

        return (SQLiteDateFormats)TypeDescriptor.GetConverter(typeof(SQLiteDateFormats)).ConvertFrom(this["DateTimeFormat"]);

      }
      set
      {
        this["DateTimeFormat"] = value;
      }
    }

    /// <summary>
    /// Helper function for retrieving values from the connectionstring
    /// </summary>
    /// <param name="keyword">The keyword to retrieve settings for</param>
    /// <param name="value">The resulting parameter value</param>
    /// <returns>Returns true if the value was found and returned</returns>
    public override bool TryGetValue(string keyword, out object value)
    {
      bool b = base.TryGetValue(keyword, out value);

      if (!_properties.ContainsKey(keyword)) return b;

      PropertyDescriptor pd = _properties[keyword] as PropertyDescriptor;

      if (pd == null) return b;

      if (b)
      {
        value = TypeDescriptor.GetConverter(pd.PropertyType).ConvertFrom(value);
      }
      else
      {

        DefaultValueAttribute att = pd.Attributes[typeof(DefaultValueAttribute)] as DefaultValueAttribute;
        if (att != null)
        {






          value = att.Value;
          b = true;
        }
      }
      return b;
    }
  }
#endif
}

Changes to System.Data.SQLite/SQLiteConvert.cs.

6
7
8
9
10
11
12






13
14
15
16
17
18
19
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
471
472
473
474
475
476
477
478


479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517

518
519
520
521
522
523
524



525
526
527
528
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Runtime.InteropServices;
  using System.Collections.Generic;







  /// <summary>
  /// SQLite has very limited types, and is inherently text-based.  The first 5 types below represent the sum of all types SQLite
  /// understands.  The DateTime extension to the spec is for internal use only.
  /// </summary>
  public enum TypeAffinity
  {
................................................................................

  /// <summary>
  /// This implementation of SQLite for ADO.NET can process date/time fields in databases in only one of two formats.  Ticks and ISO8601.
  /// Ticks is inherently more accurate, but less compatible with 3rd party tools that query the database, and renders the DateTime field
  /// unreadable without post-processing.
  /// ISO8601 is more compatible, readable, fully-processable, but less accurate as it doesn't provide time down to fractions of a second.
  /// </summary>
  public enum DateTimeFormat
  {
    /// <summary>
    /// Using ticks is more accurate but less compatible with other viewers and utilities that access your database.
    /// </summary>
    Ticks = 0,
    /// <summary>
    /// The default format for this provider.  More compatible with SQLite's intended usage of datetimes, but overall less accurate than Ticks as it doesn't
................................................................................
    /// <summary>
    /// An UTF-8 Encoding instance, so we can convert strings to and from UTF8
    /// </summary>
    private static Text.UTF8Encoding _utf8 = new Text.UTF8Encoding();
    /// <summary>
    /// The default DateTime format for this instance
    /// </summary>
    private DateTimeFormat _datetimeFormat;
    /// <summary>
    /// Initializes the conversion class
    /// </summary>
    /// <param name="fmt">The default date/time format to use for this instance</param>
    internal SQLiteConvert(DateTimeFormat fmt)
    {
      _datetimeFormat = fmt;
    }

    #region UTF-8 Conversion Functions
    /// <summary>
    /// Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
................................................................................
    /// </remarks>
    /// <param name="dateText">The string containing either a Tick value or an ISO8601-format string</param>
    /// <returns>A DateTime value</returns>
    public DateTime ToDateTime(string dateText)
    {
      switch (_datetimeFormat)
      {
        case DateTimeFormat.Ticks:
          return new DateTime(Convert.ToInt64(dateText, System.Globalization.CultureInfo.InvariantCulture));
        default:
          return DateTime.ParseExact(dateText, _datetimeFormats, System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None);
      }
    }

    /// <summary>
................................................................................
    /// </summary>
    /// <param name="dateValue">The DateTime value to convert</param>
    /// <returns>Either a string consisting of the tick count for DateTimeFormat.Ticks, or a date/time in ISO8601 format.</returns>
    public string ToString(DateTime dateValue)
    {
      switch (_datetimeFormat)
      {
        case DateTimeFormat.Ticks:
          return dateValue.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture);
        default:
          return dateValue.ToString(_datetimeFormats[0], System.Globalization.CultureInfo.InvariantCulture);
      }
    }

    /// <summary>
................................................................................
    /// <summary>
    /// For a given type name, return a closest-match .NET type
    /// </summary>
    /// <param name="Name">The name of the type to match</param>
    /// <returns>The .NET DBType the text evaluates to.</returns>
    internal static DbType TypeNameToDbType(string Name)
    {
      if (Name == null) return DbType.Object;



      int x = _typeNames.Length;
      for (int n = 0; n < x; n++)
      {
        if (System.Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(Name, _typeNames[n].typeName, System.Globalization.CompareOptions.IgnoreCase) > -1)
          return _typeNames[n].dataType; 
      }
      return DbType.Object;
    }
    #endregion

    private static SQLiteTypeNames[] _typeNames = {
      new SQLiteTypeNames("LONGTEXT", DbType.String),
      new SQLiteTypeNames("LONGCHAR", DbType.String),
      new SQLiteTypeNames("SMALLINT", DbType.Int16),
      new SQLiteTypeNames("BIGINT", DbType.Int64),
      new SQLiteTypeNames("COUNTER", DbType.Int64),
      new SQLiteTypeNames("AUTOINCREMENT", DbType.Int64),
      new SQLiteTypeNames("IDENTITY", DbType.Int64),
      new SQLiteTypeNames("LONG", DbType.Int64),
      new SQLiteTypeNames("TINYINT", DbType.Byte),
      new SQLiteTypeNames("INTEGER", DbType.Int64),
      new SQLiteTypeNames("INT", DbType.Int32),



      new SQLiteTypeNames("TEXT", DbType.String),
      new SQLiteTypeNames("DOUBLE", DbType.Double),
      new SQLiteTypeNames("FLOAT", DbType.Double),
      new SQLiteTypeNames("REAL", DbType.Single),
      new SQLiteTypeNames("BIT", DbType.Boolean),
      new SQLiteTypeNames("YESNO", DbType.Boolean),
      new SQLiteTypeNames("LOGICAL", DbType.Boolean),
      new SQLiteTypeNames("BOOL", DbType.Boolean),
      new SQLiteTypeNames("NUMERIC", DbType.Decimal),
      new SQLiteTypeNames("DECIMAL", DbType.Decimal),
      new SQLiteTypeNames("MONEY", DbType.Decimal),
      new SQLiteTypeNames("CURRENCY", DbType.Decimal),
      new SQLiteTypeNames("TIME", DbType.DateTime),
      new SQLiteTypeNames("DATE", DbType.DateTime),
      new SQLiteTypeNames("BLOB", DbType.Binary),
      new SQLiteTypeNames("BINARY", DbType.Binary),

      new SQLiteTypeNames("IMAGE", DbType.Binary),
      new SQLiteTypeNames("GENERAL", DbType.Binary),
      new SQLiteTypeNames("OLEOBJECT", DbType.Binary),
      new SQLiteTypeNames("GUID", DbType.Guid),
      new SQLiteTypeNames("UNIQUEIDENTIFIER", DbType.Guid),
      new SQLiteTypeNames("MEMO", DbType.String),
      new SQLiteTypeNames("NOTE", DbType.String),



      new SQLiteTypeNames("CHAR", DbType.String),
    };
  }
}







>
>
>
>
>
>







 







|







 







|




|







 







|







 







|







 







|
>
>




|







<
<
<
<







>
>
>



|












>







>
>
>
|



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498




499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Runtime.InteropServices;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Globalization;

#if !PLATFORM_COMPACTFRAMEWORK 
  using System.ComponentModel.Design;
#endif

  /// <summary>
  /// SQLite has very limited types, and is inherently text-based.  The first 5 types below represent the sum of all types SQLite
  /// understands.  The DateTime extension to the spec is for internal use only.
  /// </summary>
  public enum TypeAffinity
  {
................................................................................

  /// <summary>
  /// This implementation of SQLite for ADO.NET can process date/time fields in databases in only one of two formats.  Ticks and ISO8601.
  /// Ticks is inherently more accurate, but less compatible with 3rd party tools that query the database, and renders the DateTime field
  /// unreadable without post-processing.
  /// ISO8601 is more compatible, readable, fully-processable, but less accurate as it doesn't provide time down to fractions of a second.
  /// </summary>
  public enum SQLiteDateFormats
  {
    /// <summary>
    /// Using ticks is more accurate but less compatible with other viewers and utilities that access your database.
    /// </summary>
    Ticks = 0,
    /// <summary>
    /// The default format for this provider.  More compatible with SQLite's intended usage of datetimes, but overall less accurate than Ticks as it doesn't
................................................................................
    /// <summary>
    /// An UTF-8 Encoding instance, so we can convert strings to and from UTF8
    /// </summary>
    private static Text.UTF8Encoding _utf8 = new Text.UTF8Encoding();
    /// <summary>
    /// The default DateTime format for this instance
    /// </summary>
    private SQLiteDateFormats _datetimeFormat;
    /// <summary>
    /// Initializes the conversion class
    /// </summary>
    /// <param name="fmt">The default date/time format to use for this instance</param>
    internal SQLiteConvert(SQLiteDateFormats fmt)
    {
      _datetimeFormat = fmt;
    }

    #region UTF-8 Conversion Functions
    /// <summary>
    /// Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
................................................................................
    /// </remarks>
    /// <param name="dateText">The string containing either a Tick value or an ISO8601-format string</param>
    /// <returns>A DateTime value</returns>
    public DateTime ToDateTime(string dateText)
    {
      switch (_datetimeFormat)
      {
        case SQLiteDateFormats.Ticks:
          return new DateTime(Convert.ToInt64(dateText, System.Globalization.CultureInfo.InvariantCulture));
        default:
          return DateTime.ParseExact(dateText, _datetimeFormats, System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None);
      }
    }

    /// <summary>
................................................................................
    /// </summary>
    /// <param name="dateValue">The DateTime value to convert</param>
    /// <returns>Either a string consisting of the tick count for DateTimeFormat.Ticks, or a date/time in ISO8601 format.</returns>
    public string ToString(DateTime dateValue)
    {
      switch (_datetimeFormat)
      {
        case SQLiteDateFormats.Ticks:
          return dateValue.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture);
        default:
          return dateValue.ToString(_datetimeFormats[0], System.Globalization.CultureInfo.InvariantCulture);
      }
    }

    /// <summary>
................................................................................
    /// <summary>
    /// For a given type name, return a closest-match .NET type
    /// </summary>
    /// <param name="Name">The name of the type to match</param>
    /// <returns>The .NET DBType the text evaluates to.</returns>
    internal static DbType TypeNameToDbType(string Name)
    {
      if (String.IsNullOrEmpty(Name)) return DbType.Object;

      Name = Name.ToUpper(CultureInfo.InvariantCulture);

      int x = _typeNames.Length;
      for (int n = 0; n < x; n++)
      {
        if (Name.StartsWith(_typeNames[n].typeName))
          return _typeNames[n].dataType; 
      }
      return DbType.Object;
    }
    #endregion

    private static SQLiteTypeNames[] _typeNames = {




      new SQLiteTypeNames("COUNTER", DbType.Int64),
      new SQLiteTypeNames("AUTOINCREMENT", DbType.Int64),
      new SQLiteTypeNames("IDENTITY", DbType.Int64),
      new SQLiteTypeNames("LONG", DbType.Int64),
      new SQLiteTypeNames("TINYINT", DbType.Byte),
      new SQLiteTypeNames("INTEGER", DbType.Int64),
      new SQLiteTypeNames("INT", DbType.Int32),
      new SQLiteTypeNames("VARCHAR", DbType.String),
      new SQLiteTypeNames("NVARCHAR", DbType.String),
      new SQLiteTypeNames("CHAR", DbType.String),
      new SQLiteTypeNames("TEXT", DbType.String),
      new SQLiteTypeNames("DOUBLE", DbType.Double),
      new SQLiteTypeNames("FLOAT", DbType.Double),
      new SQLiteTypeNames("REAL", DbType.Single),          
      new SQLiteTypeNames("BIT", DbType.Boolean),
      new SQLiteTypeNames("YESNO", DbType.Boolean),
      new SQLiteTypeNames("LOGICAL", DbType.Boolean),
      new SQLiteTypeNames("BOOL", DbType.Boolean),
      new SQLiteTypeNames("NUMERIC", DbType.Decimal),
      new SQLiteTypeNames("DECIMAL", DbType.Decimal),
      new SQLiteTypeNames("MONEY", DbType.Decimal),
      new SQLiteTypeNames("CURRENCY", DbType.Decimal),
      new SQLiteTypeNames("TIME", DbType.DateTime),
      new SQLiteTypeNames("DATE", DbType.DateTime),
      new SQLiteTypeNames("BLOB", DbType.Binary),
      new SQLiteTypeNames("BINARY", DbType.Binary),
      new SQLiteTypeNames("VARBINARY", DbType.Binary),
      new SQLiteTypeNames("IMAGE", DbType.Binary),
      new SQLiteTypeNames("GENERAL", DbType.Binary),
      new SQLiteTypeNames("OLEOBJECT", DbType.Binary),
      new SQLiteTypeNames("GUID", DbType.Guid),
      new SQLiteTypeNames("UNIQUEIDENTIFIER", DbType.Guid),
      new SQLiteTypeNames("MEMO", DbType.String),
      new SQLiteTypeNames("NOTE", DbType.String),
      new SQLiteTypeNames("LONGTEXT", DbType.String),
      new SQLiteTypeNames("LONGCHAR", DbType.String),
      new SQLiteTypeNames("SMALLINT", DbType.Int16),
      new SQLiteTypeNames("BIGINT", DbType.Int64),
    };
  }
}

Changes to System.Data.SQLite/SQLiteDataAdapter.cs.

7
8
9
10
11
12
13













14
15
16
17
18



19
20
21
22
23
24
25
..
51
52
53
54
55
56
57
58







59




























































namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;














  /// <summary>
  /// SQLite implementation of DbDataAdapter.
  /// </summary>
  public sealed class SQLiteDataAdapter : DbDataAdapter
  {



    /// <overloads>
    /// This class is just a shell around the DbDataAdapter.  Nothing from DbDataAdapter is overridden here, just a few constructors are defined.
    /// </overloads>
    /// <summary>
    /// Default constructor.
    /// </summary>
    public SQLiteDataAdapter()
................................................................................
    /// <param name="commandText">The select command text to use to construct a select command.</param>
    /// <param name="connectionString">A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.</param>
    public SQLiteDataAdapter(string commandText, string connectionString)
    {
      SQLiteConnection cnn = new SQLiteConnection(connectionString);
      SelectCommand = new SQLiteCommand(commandText, cnn);
    }
  }







}


































































>
>
>
>
>
>
>
>
>
>
>
>
>





>
>
>







 







|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;

  /// <summary>
  /// Delegate for receiving row updating events
  /// </summary>
  /// <param name="sender">The SQLiteDataAdapter raising the event</param>
  /// <param name="e">The event's specifics</param>
  public delegate void SQLiteRowUpdatingEventHandler(object sender, RowUpdatingEventArgs e);
  /// <summary>
  /// Delegate for receiving row updated events
  /// </summary>
  /// <param name="sender">The SQLiteDataAdapter raising the event</param>
  /// <param name="e">The event's specifics</param>
  public delegate void SQLiteRowUpdatedEventHandler(object sender, RowUpdatedEventArgs e);

  /// <summary>
  /// SQLite implementation of DbDataAdapter.
  /// </summary>
  public sealed class SQLiteDataAdapter : DbDataAdapter
  {
    private static readonly object RowUpdatingEvent = new object();
    private static readonly object RowUpdatedEvent = new object();

    /// <overloads>
    /// This class is just a shell around the DbDataAdapter.  Nothing from DbDataAdapter is overridden here, just a few constructors are defined.
    /// </overloads>
    /// <summary>
    /// Default constructor.
    /// </summary>
    public SQLiteDataAdapter()
................................................................................
    /// <param name="commandText">The select command text to use to construct a select command.</param>
    /// <param name="connectionString">A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.</param>
    public SQLiteDataAdapter(string commandText, string connectionString)
    {
      SQLiteConnection cnn = new SQLiteConnection(connectionString);
      SelectCommand = new SQLiteCommand(commandText, cnn);
    }

    /// <summary>
    /// Row updating event sink.  Hook your delegate in here
    /// </summary>
    public event SQLiteRowUpdatingEventHandler RowUpdating
    {
      add { base.Events.AddHandler(RowUpdatingEvent, value); }
      remove { base.Events.RemoveHandler(RowUpdatingEvent, value); }
    }

    /// <summary>
    /// Row updated event.  Hook your delegate in here
    /// </summary>
    public event SQLiteRowUpdatedEventHandler RowUpdated
    {
      add { base.Events.AddHandler(RowUpdatedEvent, value); }
      remove { base.Events.RemoveHandler(RowUpdatedEvent, value); }
    }

    /// <summary>
    /// Creates a row updated event object
    /// </summary>
    /// <param name="dataRow">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="command">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="statementType">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="tableMapping">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <returns>A RowUpdatedEventArgs class</returns>
    protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
    {
      return new RowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
    }

    /// <summary>
    /// Creates a row updating event object
    /// </summary>
    /// <param name="dataRow">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="command">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="statementType">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <param name="tableMapping">Forwarded to RowUpdatedEventArgs constructor</param>
    /// <returns>A RowUpdatedEventArgs class</returns>
    protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
    {
      return new RowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
    }

    /// <summary>
    /// Raised by the underlying DbDataAdapter when a row is being updated
    /// </summary>
    /// <param name="value">The event's specifics</param>
    protected override void OnRowUpdating(RowUpdatingEventArgs value)
    {
      SQLiteRowUpdatingEventHandler eventDelegate = base.Events[RowUpdatingEvent] as SQLiteRowUpdatingEventHandler;
      if (eventDelegate != null)
        eventDelegate(this, value);
    }

    /// <summary>
    /// Raised by DbDataAdapter after a row is updated
    /// </summary>
    /// <param name="value">The event's specifics</param>
    protected override void OnRowUpdated(RowUpdatedEventArgs value)
    {
      SQLiteRowUpdatedEventHandler eventDelegate = base.Events[RowUpdatedEvent] as SQLiteRowUpdatedEventHandler;
      if (eventDelegate != null)
        eventDelegate(this, value);
    }
  }
}

Changes to System.Data.SQLite/SQLiteDataReader.cs.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443





444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
...
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523

524
525
526

527

528
529
530

531
532
533

534
535
536
537
538
539
540
541
542

543
544
545
546
547
548
549
550

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;


  /// <summary>
  /// SQLite implementation of DbDataReader.
  /// </summary>
  public sealed class SQLiteDataReader : DbDataReader
  {
    /// <summary>
................................................................................
    /// Retrieves the column as a boolean value
    /// </summary>
    /// <param name="i">The index of the column to retrieve</param>
    /// <returns>bool</returns>
    public override bool GetBoolean(int i)
    {
      VerifyType(i, DbType.Boolean);
      return Convert.ToBoolean(GetValue(i), System.Globalization.CultureInfo.CurrentCulture);
    }

    /// <summary>
    /// Retrieves the column as a single byte value
    /// </summary>
    /// <param name="i">The index of the column to retrieve</param>
    /// <returns>byte</returns>
................................................................................
    /// original connection's existing statements or state.  Any attached databases are re-attached to the new connection.
    /// </remarks>
    /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns>
    public override DataTable GetSchemaTable()
    {
      CheckClosed();

      DataTable tbl = new DataTable("Schema");
      string[] arName;
      string strTable;
      string strCatalog;
      DataRow row;

      tbl.Locale = System.Globalization.CultureInfo.InvariantCulture;
      tbl.Columns.Add(SchemaTableColumn.ColumnName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.ColumnOrdinal, typeof(Int32));
      tbl.Columns.Add(SchemaTableColumn.ColumnSize, typeof(Int32));
      tbl.Columns.Add(SchemaTableColumn.NumericPrecision, typeof(Int32));
      tbl.Columns.Add(SchemaTableColumn.NumericScale, typeof(Int32));
      tbl.Columns.Add(SchemaTableColumn.DataType, typeof(Type));
      tbl.Columns.Add(SchemaTableColumn.ProviderType, typeof(Int32));





      tbl.Columns.Add(SchemaTableColumn.IsLong, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.AllowDBNull, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsReadOnly, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsRowVersion, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.IsUnique, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.IsKey, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsAutoIncrement, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.BaseSchemaName, typeof(String));
      tbl.Columns.Add(SchemaTableOptionalColumn.BaseCatalogName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.BaseTableName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.BaseColumnName, typeof(String));
      tbl.Columns.Add(SchemaTableOptionalColumn.BaseColumnNamespace, typeof(string));
      tbl.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(object));

      tbl.BeginLoadData();

      SQLiteConnection cnn = (SQLiteConnection)_command.Connection;

      try
................................................................................

              // Default settings for the column
              row[SchemaTableColumn.ColumnName] = GetName(n);
              row[SchemaTableColumn.ColumnOrdinal] = n;
              row[SchemaTableColumn.ColumnSize] = 0;
              row[SchemaTableColumn.NumericPrecision] = 0;
              row[SchemaTableColumn.NumericScale] = 0;
              row[SchemaTableColumn.DataType] = GetFieldType(n);
              row[SchemaTableColumn.ProviderType] = GetSQLiteType(n).Type;
              row[SchemaTableColumn.IsLong] = false;
              row[SchemaTableColumn.AllowDBNull] = true;
              row[SchemaTableOptionalColumn.IsReadOnly] = true;
              row[SchemaTableOptionalColumn.IsRowVersion] = false;
              row[SchemaTableColumn.IsUnique] = false;
              row[SchemaTableColumn.IsKey] = false;
................................................................................

              if (arName.Length > 2)
                strCatalog = arName[arName.Length - 3];

              // If we have a table-bound column, extract the extra information from it
              if (arName.Length > 1)
              {
                using (SQLiteCommand cmdTable = new SQLiteCommand(String.Format(System.Globalization.CultureInfo.CurrentCulture, "PRAGMA [{1}].TABLE_INFO([{0}])", strTable, strCatalog), cnn))
                {
                  if (arName.Length < 3) strCatalog = "";

                  using (DbDataReader rdTable = cmdTable.ExecuteReader())
                  {
                    while (rdTable.Read())
                    {
                      if (String.Compare(arName[arName.Length - 1], rdTable.GetString(1), true, System.Globalization.CultureInfo.CurrentCulture) == 0)
                      {
                        string strType = rdTable.GetString(2);
                        string[] arSize = strType.Split('(');
                        if (arSize.Length > 1)
                        {

                          arSize = arSize[1].Split(')');
                          if (arSize.Length > 1)
                            row["ColumnSize"] = Convert.ToInt32(arSize[0], System.Globalization.CultureInfo.InvariantCulture);

                        }

                        bool bNotNull = rdTable.GetBoolean(3);
                        bool bPrimaryKey = rdTable.GetBoolean(5);


                        row[SchemaTableColumn.BaseTableName] = strTable;
                        row[SchemaTableColumn.BaseColumnName] = rdTable.GetString(1);
                        if (strCatalog.Length > 0)

                        {
                          row[SchemaTableOptionalColumn.BaseColumnNamespace] = strCatalog;
                          row[SchemaTableColumn.BaseSchemaName] = strCatalog;
                        }

                        row[SchemaTableColumn.AllowDBNull] = (!bNotNull && !bPrimaryKey);
                        row[SchemaTableColumn.IsUnique] = bPrimaryKey;
                        row[SchemaTableColumn.IsKey] = bPrimaryKey;
                        row[SchemaTableOptionalColumn.IsAutoIncrement] = (bPrimaryKey && String.Compare(strType, "Integer", true, System.Globalization.CultureInfo.InvariantCulture) == 0);

                        row[SchemaTableOptionalColumn.IsReadOnly] = !(bool)row[SchemaTableOptionalColumn.IsAutoIncrement];
                        if (rdTable.IsDBNull(4) == false)
                          row[SchemaTableOptionalColumn.DefaultValue] = rdTable[4];
                        break;
                      }
                    }
                  }
                }







>







 







|







 







|





|

|
|
|
|
|
|
>
>
>
>
>
|

|
<
|
|

|
|
|
|
|







 







<







 







|

|





|





>


<
>

>



>


<
>

|
<





|
>
|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
...
484
485
486
487
488
489
490

491
492
493
494
495
496
497
...
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530

531
532
533
534
535
536
537
538
539

540
541
542

543
544
545
546
547
548
549
550
551
552
553
554
555
556
557

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;
  using System.Globalization;

  /// <summary>
  /// SQLite implementation of DbDataReader.
  /// </summary>
  public sealed class SQLiteDataReader : DbDataReader
  {
    /// <summary>
................................................................................
    /// Retrieves the column as a boolean value
    /// </summary>
    /// <param name="i">The index of the column to retrieve</param>
    /// <returns>bool</returns>
    public override bool GetBoolean(int i)
    {
      VerifyType(i, DbType.Boolean);
      return Convert.ToBoolean(GetValue(i), CultureInfo.CurrentCulture);
    }

    /// <summary>
    /// Retrieves the column as a single byte value
    /// </summary>
    /// <param name="i">The index of the column to retrieve</param>
    /// <returns>byte</returns>
................................................................................
    /// original connection's existing statements or state.  Any attached databases are re-attached to the new connection.
    /// </remarks>
    /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns>
    public override DataTable GetSchemaTable()
    {
      CheckClosed();

      DataTable tbl = new DataTable("SchemaTable");
      string[] arName;
      string strTable;
      string strCatalog;
      DataRow row;

      tbl.Locale = CultureInfo.InvariantCulture;
      tbl.Columns.Add(SchemaTableColumn.ColumnName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.ColumnOrdinal, typeof(int));
      tbl.Columns.Add(SchemaTableColumn.ColumnSize, typeof(int));
      tbl.Columns.Add(SchemaTableColumn.NumericPrecision, typeof(short));
      tbl.Columns.Add(SchemaTableColumn.NumericScale, typeof(short));
      tbl.Columns.Add(SchemaTableColumn.IsUnique, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.IsKey, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.BaseServerName, typeof(string));
      tbl.Columns.Add(SchemaTableOptionalColumn.BaseCatalogName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.BaseColumnName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.BaseSchemaName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.BaseTableName, typeof(String));
      tbl.Columns.Add(SchemaTableColumn.DataType, typeof(Type));
      tbl.Columns.Add(SchemaTableColumn.AllowDBNull, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.ProviderType, typeof(int));

      tbl.Columns.Add(SchemaTableColumn.IsAliased, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.IsExpression, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsAutoIncrement, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsRowVersion, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsHidden, typeof(Boolean));
      tbl.Columns.Add(SchemaTableColumn.IsLong, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.IsReadOnly, typeof(Boolean));
      tbl.Columns.Add(SchemaTableOptionalColumn.ProviderSpecificDataType, typeof(Type));
      tbl.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(object));

      tbl.BeginLoadData();

      SQLiteConnection cnn = (SQLiteConnection)_command.Connection;

      try
................................................................................

              // Default settings for the column
              row[SchemaTableColumn.ColumnName] = GetName(n);
              row[SchemaTableColumn.ColumnOrdinal] = n;
              row[SchemaTableColumn.ColumnSize] = 0;
              row[SchemaTableColumn.NumericPrecision] = 0;
              row[SchemaTableColumn.NumericScale] = 0;

              row[SchemaTableColumn.ProviderType] = GetSQLiteType(n).Type;
              row[SchemaTableColumn.IsLong] = false;
              row[SchemaTableColumn.AllowDBNull] = true;
              row[SchemaTableOptionalColumn.IsReadOnly] = true;
              row[SchemaTableOptionalColumn.IsRowVersion] = false;
              row[SchemaTableColumn.IsUnique] = false;
              row[SchemaTableColumn.IsKey] = false;
................................................................................

              if (arName.Length > 2)
                strCatalog = arName[arName.Length - 3];

              // If we have a table-bound column, extract the extra information from it
              if (arName.Length > 1)
              {
                using (SQLiteCommand cmdTable = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "PRAGMA [{1}].TABLE_INFO([{0}])", strTable, strCatalog), cnn))
                {
                  if (arName.Length < 3) strCatalog = "main";

                  using (DbDataReader rdTable = cmdTable.ExecuteReader())
                  {
                    while (rdTable.Read())
                    {
                      if (String.Compare(arName[arName.Length - 1], rdTable.GetString(1), true, CultureInfo.CurrentCulture) == 0)
                      {
                        string strType = rdTable.GetString(2);
                        string[] arSize = strType.Split('(');
                        if (arSize.Length > 1)
                        {
                          strType = arSize[0];
                          arSize = arSize[1].Split(')');
                          if (arSize.Length > 1)

                            row[SchemaTableColumn.ColumnSize] = Convert.ToInt32(arSize[0], CultureInfo.InvariantCulture);
                        }

                        bool bNotNull = rdTable.GetBoolean(3);
                        bool bPrimaryKey = rdTable.GetBoolean(5);

                        row[SchemaTableColumn.DataType] = GetFieldType(n);
                        row[SchemaTableColumn.BaseTableName] = strTable;
                        row[SchemaTableColumn.BaseColumnName] = rdTable.GetString(1);

                        if (String.IsNullOrEmpty(strCatalog) == false)
                        {
                          row[SchemaTableOptionalColumn.BaseCatalogName] = strCatalog;

                        }

                        row[SchemaTableColumn.AllowDBNull] = (!bNotNull && !bPrimaryKey);
                        row[SchemaTableColumn.IsUnique] = bPrimaryKey;
                        row[SchemaTableColumn.IsKey] = bPrimaryKey;
                        row[SchemaTableOptionalColumn.IsAutoIncrement] = (bPrimaryKey &&
                            String.Compare(strType, "integer", true, CultureInfo.InvariantCulture) == 0);
                        row[SchemaTableOptionalColumn.IsReadOnly] = (bool)row[SchemaTableOptionalColumn.IsAutoIncrement];
                        if (rdTable.IsDBNull(4) == false)
                          row[SchemaTableOptionalColumn.DefaultValue] = rdTable[4];
                        break;
                      }
                    }
                  }
                }

Changes to System.Data.SQLite/SQLiteParameter.cs.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
404
405
406
407
408
409
410
411
412







413




  using System;
  using System.Data;
  using System.Data.Common;

  /// <summary>
  /// SQLite implementation of DbParameter.
  /// </summary>
  public sealed class SQLiteParameter : DbParameter
  {
    /// <summary>
    /// The data type of the parameter
    /// </summary>
    private int            _dbType;
    /// <summary>
    /// The version information for mapping the parameter
................................................................................
      }
      set
      {
        _objValue = value;
        if (_dbType == -1 && _objValue != null && _objValue != DBNull.Value) // If the DbType has never been assigned, try to glean one from the value's datatype 
          _dbType = (int)SQLiteConvert.TypeToDbType(_objValue.GetType());
      }
    }    
  }







}











|







 







|
|
>
>
>
>
>
>
>
|
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
  using System;
  using System.Data;
  using System.Data.Common;

  /// <summary>
  /// SQLite implementation of DbParameter.
  /// </summary>
  public sealed class SQLiteParameter : DbParameter, ICloneable
  {
    /// <summary>
    /// The data type of the parameter
    /// </summary>
    private int            _dbType;
    /// <summary>
    /// The version information for mapping the parameter
................................................................................
      }
      set
      {
        _objValue = value;
        if (_dbType == -1 && _objValue != null && _objValue != DBNull.Value) // If the DbType has never been assigned, try to glean one from the value's datatype 
          _dbType = (int)SQLiteConvert.TypeToDbType(_objValue.GetType());
      }
    }

    /// <summary>
    /// Clones a parameter
    /// </summary>
    /// <returns>A new, unassociated SQLiteParameter</returns>
    public object Clone()
    {
      SQLiteParameter newparam = new SQLiteParameter(ParameterName, this.DbType, Size, Direction, IsNullable, 0, 0, SourceColumn, SourceVersion, Value);

      return newparam;
    }
  }
}

Changes to System.Data.SQLite/SQLiteParameterCollection.cs.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
...
257
258
259
260
261
262
263
264

265
266
267
268
269
270
271
...
353
354
355
356
357
358
359

360
361
362
363

364
365
366
367
368
369
370
371


372
373

374
375
376
377


















378
379
380
381
382
383
384

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;


  /// <summary>
  /// SQLite implementation of DbParameterCollection.
  /// </summary>
  public sealed class SQLiteParameterCollection : DbParameterCollection
  {
    /// <summary>
................................................................................
    /// <param name="parameterName">The name of the parameter to find</param>
    /// <returns>-1 if not found, otherwise a zero-based index of the parameter</returns>
    public override int IndexOf(string parameterName)
    {
      int x = _parameterList.Count;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(parameterName, _parameterList[n].ParameterName, true, System.Globalization.CultureInfo.CurrentCulture) == 0) return n;

      }
      return -1;
    }

    /// <summary>
    /// Returns the index of a parameter
    /// </summary>
................................................................................
    internal void MapParameters()
    {
      if (_unboundFlag == false || _parameterList.Count == 0) return;

      int nUnnamed = 0;
      string s;
      int n;

      SQLiteStatement stmt;

      foreach(SQLiteParameter p in _parameterList)
      {

        s = p.ParameterName;
        if (s == null)
        {
          s = String.Format(System.Globalization.CultureInfo.InvariantCulture, ";{0}", nUnnamed);
          nUnnamed++;
        }

        int x = _command._statementList.Length;


        for (n = 0; n < x; n++)
        {

          stmt = _command._statementList[n];
          if (stmt._paramNames != null)
          {
            stmt.MapParameter(s, p);


















          }
        }
      }
      _unboundFlag = false;
    }
  }
}







>







 







|
>







 







>




>



|




>
>


>



|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
...
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

namespace System.Data.SQLite
{
  using System;
  using System.Data;
  using System.Data.Common;
  using System.Collections.Generic;
  using System.Globalization;

  /// <summary>
  /// SQLite implementation of DbParameterCollection.
  /// </summary>
  public sealed class SQLiteParameterCollection : DbParameterCollection
  {
    /// <summary>
................................................................................
    /// <param name="parameterName">The name of the parameter to find</param>
    /// <returns>-1 if not found, otherwise a zero-based index of the parameter</returns>
    public override int IndexOf(string parameterName)
    {
      int x = _parameterList.Count;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(parameterName, _parameterList[n].ParameterName, true, CultureInfo.CurrentCulture) == 0)
          return n;
      }
      return -1;
    }

    /// <summary>
    /// Returns the index of a parameter
    /// </summary>
................................................................................
    internal void MapParameters()
    {
      if (_unboundFlag == false || _parameterList.Count == 0) return;

      int nUnnamed = 0;
      string s;
      int n;
      int y = -1;
      SQLiteStatement stmt;

      foreach(SQLiteParameter p in _parameterList)
      {
        y ++;
        s = p.ParameterName;
        if (s == null)
        {
          s = String.Format(CultureInfo.InvariantCulture, ";{0}", nUnnamed);
          nUnnamed++;
        }

        int x = _command._statementList.Length;
        bool isMapped = false;

        for (n = 0; n < x; n++)
        {
          isMapped = false;
          stmt = _command._statementList[n];
          if (stmt._paramNames != null)
          {
            if (stmt.MapParameter(s, p) == true)
              isMapped = true;
          }
        }

        // If the parameter has a name, but the SQL statement uses unnamed references, this can happen -- attempt to map
        // the parameter by its index in the collection
        if (isMapped == false)
        {
          s = String.Format(CultureInfo.InvariantCulture, ";{0}", y);

          for (n = 0; n < x; n++)
          {
            stmt = _command._statementList[n];
            if (stmt._paramNames != null)
            {
              if (stmt.MapParameter(s, p) == true)
                isMapped = true;
            }
          }
        }
      }
      _unboundFlag = false;
    }
  }
}

Changes to System.Data.SQLite/SQLiteStatement.cs.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Collections.Generic;


  /// <summary>
  /// Represents a single SQL statement in SQLite.
  /// </summary>
  internal sealed class SQLiteStatement : IDisposable
  {
    /// <summary>
................................................................................
        _paramValues = new SQLiteParameter[n];

        for (x = 0; x < n; x++)
        {
          s = _sql.Bind_ParamName(this, x + 1);
          if (String.IsNullOrEmpty(s))
          {
            s = String.Format(System.Globalization.CultureInfo.InvariantCulture, ";{0}", nCmdStart);
            nCmdStart++;
          }
          _paramNames[x] = s;
          _paramValues[x] = null;
        }
      }
    }
................................................................................

    /// <summary>
    /// Called by SQLiteParameterCollection, this function determines if the specified parameter name belongs to
    /// this statement, and if so, keeps a reference to the parameter so it can be bound later.
    /// </summary>
    /// <param name="s">The parameter name to map</param>
    /// <param name="p">The parameter to assign it</param>
    internal void MapParameter(string s, SQLiteParameter p)
    {
      if (_paramNames == null) return;

      int x = _paramNames.Length;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(_paramNames[n], s, true, System.Globalization.CultureInfo.CurrentCulture) == 0)
        {
          _paramValues[n] = p;
          break;
        }
      }

    }

    #region IDisposable Members
    /// <summary>
    /// Disposes and finalizes the statement
    /// </summary>
    public void Dispose()
................................................................................
      }

      switch (param.DbType)
      {
        case DbType.Date:
        case DbType.Time:
        case DbType.DateTime:
          _sql.Bind_DateTime(this, index, Convert.ToDateTime(obj, System.Globalization.CultureInfo.CurrentCulture));
          break;
        case DbType.Int64:
        case DbType.UInt64:
          _sql.Bind_Int64(this, index, Convert.ToInt64(obj, System.Globalization.CultureInfo.CurrentCulture));
          break;
        case DbType.Boolean:
        case DbType.Int16:
        case DbType.Int32:
        case DbType.UInt16:
        case DbType.UInt32:
        case DbType.SByte:
        case DbType.Byte:
          _sql.Bind_Int32(this, index, Convert.ToInt32(obj, System.Globalization.CultureInfo.CurrentCulture));
          break;
        case DbType.Single:
        case DbType.Double:
        case DbType.Currency:
        case DbType.Decimal:
          _sql.Bind_Double(this, index, Convert.ToDouble(obj, System.Globalization.CultureInfo.CurrentCulture));
          break;
        case DbType.Binary:
          _sql.Bind_Blob(this, index, (byte[])obj);
          break;
        default:
          _sql.Bind_Text(this, index, obj.ToString());
          break;
      }
    }
  }
}







>







 







|







 







|

|




|


|


>







 







|



|








|





|











5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Collections.Generic;
  using System.Globalization;

  /// <summary>
  /// Represents a single SQL statement in SQLite.
  /// </summary>
  internal sealed class SQLiteStatement : IDisposable
  {
    /// <summary>
................................................................................
        _paramValues = new SQLiteParameter[n];

        for (x = 0; x < n; x++)
        {
          s = _sql.Bind_ParamName(this, x + 1);
          if (String.IsNullOrEmpty(s))
          {
            s = String.Format(CultureInfo.InvariantCulture, ";{0}", nCmdStart);
            nCmdStart++;
          }
          _paramNames[x] = s;
          _paramValues[x] = null;
        }
      }
    }
................................................................................

    /// <summary>
    /// Called by SQLiteParameterCollection, this function determines if the specified parameter name belongs to
    /// this statement, and if so, keeps a reference to the parameter so it can be bound later.
    /// </summary>
    /// <param name="s">The parameter name to map</param>
    /// <param name="p">The parameter to assign it</param>
    internal bool MapParameter(string s, SQLiteParameter p)
    {
      if (_paramNames == null) return false;

      int x = _paramNames.Length;
      for (int n = 0; n < x; n++)
      {
        if (String.Compare(_paramNames[n], s, true, CultureInfo.CurrentCulture) == 0)
        {
          _paramValues[n] = p;
          return true;
        }
      }
      return false;
    }

    #region IDisposable Members
    /// <summary>
    /// Disposes and finalizes the statement
    /// </summary>
    public void Dispose()
................................................................................
      }

      switch (param.DbType)
      {
        case DbType.Date:
        case DbType.Time:
        case DbType.DateTime:
          _sql.Bind_DateTime(this, index, Convert.ToDateTime(obj, CultureInfo.CurrentCulture));
          break;
        case DbType.Int64:
        case DbType.UInt64:
          _sql.Bind_Int64(this, index, Convert.ToInt64(obj, CultureInfo.CurrentCulture));
          break;
        case DbType.Boolean:
        case DbType.Int16:
        case DbType.Int32:
        case DbType.UInt16:
        case DbType.UInt32:
        case DbType.SByte:
        case DbType.Byte:
          _sql.Bind_Int32(this, index, Convert.ToInt32(obj, CultureInfo.CurrentCulture));
          break;
        case DbType.Single:
        case DbType.Double:
        case DbType.Currency:
        case DbType.Decimal:
          _sql.Bind_Double(this, index, Convert.ToDouble(obj, CultureInfo.CurrentCulture));
          break;
        case DbType.Binary:
          _sql.Bind_Blob(this, index, (byte[])obj);
          break;
        default:
          _sql.Bind_Text(this, index, obj.ToString());
          break;
      }
    }
  }
}

Changes to bin/CompactFramework/SQLite.Interop.dll.

cannot compute difference between binary files

Changes to bin/CompactFramework/System.Data.SQLite.dll.

cannot compute difference between binary files

Changes to bin/CompactFramework/testce.exe.

cannot compute difference between binary files

Changes to bin/System.Data.SQLite.dll.

cannot compute difference between binary files

Changes to bin/test.exe.

cannot compute difference between binary files

Changes to readme.htm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
19
20
21
22
23
24
25




26
27
28
29
30
31
32
..
47
48
49
50
51
52
53





















54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69


70
71
72
73
74
75
76
...
123
124
125
126
127
128
129
130
131






132














133
134
135
136
137
138
139

140
141
142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
  </head>
  <body>
    ADO.NET 2.0 SQLite Data Provider<br>
    Version 1.0.12 - Aug 5, 2005<br>
    Interop using SQLite 3.22<br>
    Written by Robert Simpson (<a href="mailto:robert@blackcastlesoft.com">robert@blackcastlesoft.com</a>)<br>
    Released to the public domain, use at your own risk!<br>
    <br>
    This provider was written and tested using the Visual Studio 2005 Beta 2 
    release.<br>
    <br>
................................................................................
    <br>
    <b></b>
    <h2>
      <b>Features:</b><br>
    </h2>
    <ul>
      <li>




      DbProviderFactory support, just add the XML below at the machine.config and/or 
      app.config level.
      <li>
        Full support for ATTACH'ed databases.&nbsp; Exposed as <i>Catalogs</i>
      in the schema.&nbsp; When cloning a connection, all attached databases are 
      automatically re-attached to the new connection.
      <li>
................................................................................
      an easy-to-use base class in which only a couple of overrides are necessary to 
      implement new SQL functions.
      <li>
        Full support for user-defined collating sequences, every bit as simple to 
        implement as user-defined functions and uses the same base class.</li></ul>
    <strong></strong>
    <h2>





















      <strong>DbFactory Support (Non-Compact Framework)</strong></h2>
    In order to use the SQLiteFactory and have the SQLite data provider enumerated 
    in the DbProviderFactories methods, you must add the following segment into 
    either your application's app.config or the system's machine.config located in 
    the %SystemRoot%\Microsoft.Net\Framework\v2.xxxx\Config folder:<br>
    <br>
    <pre>
&lt;configuration&gt;
  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;add name="SQLite Data Provider" invariant="System.Data.SQLite" support="3F" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /&gt;

    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;/configuration&gt;
</pre>
    <br>


    <h3>
      Compiling for the Compact Framework</h3>
    <p>
      Just change the target platform from Win32 to Compact Framework and 
      recompile.&nbsp; <STRONG>The Compact Framework has no support for enumerating 
        attributes in an assembly, therefore all user-defined collating sequences and 
        functions must be explicitly registered.</STRONG>&nbsp; See the <STRONG>testce</STRONG>
................................................................................
      <li>
        <FONT color="silver">Compile it. </FONT>
      </li>
    </ol>
    <b></b>
    <h2>
      <b>Version History</b></h2>
    <b>1.0.12 - August 2, 2005</b><br>
    <UL>






      <LI>














        Full support for the Compact Framework.&nbsp; Each build (Debug/Release) now 
        has a&nbsp;platform, either Win32 or Compact Framework.&nbsp; The correct 
        projects are built accordingly.&nbsp; See the&nbsp;<A href="#redist">Distributing 
          SQLite</A>
      section for information on what files need to be distributed for each 
      platform.&nbsp;
      <LI>

      Modified SQLite3.Reset() and Step() functions to transparently handle timeouts 
      while waiting on the database to become available (typically when a writer is 
      waiting on a reader to finish, or a reader is waiting on a writer to finish).
      <LI>
      Lots of code cleanup&nbsp;as suggested&nbsp;by the Code Analyzer (FxCop).
      <LI>
      Lots of updates to the helpfile.
      <LI>
        Statements&nbsp;were already prepared lazily&nbsp;in a SQLiteCommand, but 
        things are relaxed even more now.&nbsp; Statements are now only prepared if the 
        statements haven't been previously prepared and a Prepare() function is called 
        (and the command is associated with a connection) or just prior to the command 
        being executed.&nbsp;</LI></UL>

    <b>1.0.11 - August 1, 2005</b><br>
    <ul>
      <li>
        <strong>For everything except the Compact Framework, System.Data.SQLite.DLL is 
          now the <em>only</em> DLL required to use this provider!</strong>&nbsp; The 
      assembly is now a multi-module assembly, containing both the native SQLite3 
      codebase and the C# classes built on top of it.&nbsp; The Compact Framework 







|







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|





<
|


<
>




|
>
>







 







|
|
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>


|
|


<
>
|
|
|
<
<
<
<
<
<
<
<
<
<
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

185
186
187
188










189
190
191
192
193
194
195
196
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
  </head>
  <body>
    ADO.NET 2.0 SQLite Data Provider<br>
    Version 1.0.14 - Aug 16, 2005<br>
    Interop using SQLite 3.22<br>
    Written by Robert Simpson (<a href="mailto:robert@blackcastlesoft.com">robert@blackcastlesoft.com</a>)<br>
    Released to the public domain, use at your own risk!<br>
    <br>
    This provider was written and tested using the Visual Studio 2005 Beta 2 
    release.<br>
    <br>
................................................................................
    <br>
    <b></b>
    <h2>
      <b>Features:</b><br>
    </h2>
    <ul>
      <li>
      Visual Studio Design-Time Support.&nbsp; You can add a SQLite database to the 
      Servers list, design queries with the Query Designer, drag-and-drop tables onto 
      a Typed DataSet, etc.
      <LI>
      DbProviderFactory support, just add the XML below at the machine.config and/or 
      app.config level.
      <li>
        Full support for ATTACH'ed databases.&nbsp; Exposed as <i>Catalogs</i>
      in the schema.&nbsp; When cloning a connection, all attached databases are 
      automatically re-attached to the new connection.
      <li>
................................................................................
      an easy-to-use base class in which only a couple of overrides are necessary to 
      implement new SQL functions.
      <li>
        Full support for user-defined collating sequences, every bit as simple to 
        implement as user-defined functions and uses the same base class.</li></ul>
    <strong></strong>
    <h2>
      <strong>Design-Time Support (new as of 1.0.14)</strong></h2>
    <P>Until an installer is created, the steps for registering the provider for 
      design-time support are:</P>
    <OL>
      <LI>
        Register the <STRONG>System.Data.SQLite.DLL</STRONG> in the Global Assembly 
        Cache either by using the .Net 2.0 version of GACUTIL, or through <STRONG>Administrative 
          Tools -&gt; Microsoft .NET Framework 2.0 Configuration</STRONG>.
      <LI>
        Through a command-prompt or Windows Explorer, navigate to the <STRONG>SQLite.NET\bin\Designer</STRONG>
        folder and execute the <STRONG>INSTALL.CMD</STRONG>
      file.
      <LI>
        <STRONG>NOTE:&nbsp; Enabling Design-Time support for SQLite causes the SQLite 
          Provider to be registered in your machine.config.</STRONG>&nbsp;&nbsp; If you 
        have already added the XML shown below to your <STRONG>app.config</STRONG> in 
        your applications, <STRONG>you need to remove it.</STRONG>&nbsp; If you 
      don't, it will cause a unique constraint violation when you run your program.
      <LI>
        Delete the <STRONG>test.exe.config</STRONG> file from the <STRONG>SQLite.NET\bin</STRONG>
        folder -- it is no longer necessary.</LI></OL>
    <H2><STRONG>DbFactory Support (Non-Compact Framework)</STRONG></H2>
    In order to use the SQLiteFactory and have the SQLite data provider enumerated 
    in the DbProviderFactories methods, you must add the following segment into 
    either your application's app.config or the system's machine.config located in 
    the %SystemRoot%\Microsoft.Net\Framework\v2.xxxx\Config folder:<br>
    <br>

    <pre>&lt;configuration&gt;
  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;

      &lt;add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"<BR> type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.14.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" /&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;/configuration&gt;
</pre>
    <P>If you choose to install the Visual Studio Design-Time support for SQLite, you 
      must not add the above XML to your app.config.&nbsp; The installer will have 
      already added it to your machine's machine.config file.</P>
    <h3>
      Compiling for the Compact Framework</h3>
    <p>
      Just change the target platform from Win32 to Compact Framework and 
      recompile.&nbsp; <STRONG>The Compact Framework has no support for enumerating 
        attributes in an assembly, therefore all user-defined collating sequences and 
        functions must be explicitly registered.</STRONG>&nbsp; See the <STRONG>testce</STRONG>
................................................................................
      <li>
        <FONT color="silver">Compile it. </FONT>
      </li>
    </ol>
    <b></b>
    <h2>
      <b>Version History</b></h2>
    <b>1.0.14 - August 16, 2005</b><br>
    <ul>
      <li>
      Fixed a bug in the SQLiteDataAdapter due to insufficient implementation of the 
      class.&nbsp; The RowUpdating and RowUpdated events are now properly 
      implemented, but unfortunately inserting and updating data in a DataTable or 
      DataSet is now much slower.&nbsp; This is the proper design however, so the 
      changes are here to stay.
      <LI>
      Lots of schema changes to support Visual Studio's Data Designer architecture.<li>Added 
        Designer support for the provider.&nbsp; It's not 100%, but you can design 
        queries, add typed datasets and perform quite a number of tasks all within 
        Visual Studio now.</li></ul>
    <b>1.0.13 - August 8, 2005</b><br>
    <ul>
      <li>
      Fixed a named parameter bug when UseUTF16Encoding was True.
      <li>
        Fixed a performance issue in SQLite3_UTF16 involving string marshaling.</li>
    </ul>
    <b>1.0.12 - August 5, 2005</b><br>
    <ul>
      <li>
        Full support for the Compact Framework.&nbsp; Each build (Debug/Release) now 
        has a&nbsp;platform, either Win32 or Compact Framework.&nbsp; The correct 
        projects are built accordingly.&nbsp; See the&nbsp;<a href="#redist">Distributing 
          SQLite</a>
      section for information on what files need to be distributed for each 
      platform.&nbsp;

      <li>
        Modified SQLite3.Reset() and Step() functions to transparently handle timeouts 
        while waiting on the database to become available (typically when a writer is 
        waiting on a reader to finish, or a reader is waiting on a writer to finish).</li>










    </ul>
    <b>1.0.11 - August 1, 2005</b><br>
    <ul>
      <li>
        <strong>For everything except the Compact Framework, System.Data.SQLite.DLL is 
          now the <em>only</em> DLL required to use this provider!</strong>&nbsp; The 
      assembly is now a multi-module assembly, containing both the native SQLite3 
      codebase and the C# classes built on top of it.&nbsp; The Compact Framework 

Changes to test/Program.cs.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//      cnn.Open();

//      TestCases.Run(fact, cnn);

      using (cnn = new SQLiteConnection())
      {
        fact = DbProviderFactories.GetFactory("System.Data.SQLite");
        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off";
        cnn.Open();
        TestCases.Run(fact, cnn);
      }

      System.IO.File.Delete("test.db3");

      Console.ReadKey();
    }
  }
}







|










25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//      cnn.Open();

//      TestCases.Run(fact, cnn);

      using (cnn = new SQLiteConnection())
      {
        fact = DbProviderFactories.GetFactory("System.Data.SQLite");
        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off;UseUTF16Encoding=TRUE";
        cnn.Open();
        TestCases.Run(fact, cnn);
      }

      System.IO.File.Delete("test.db3");

      Console.ReadKey();
    }
  }
}

Changes to testce/Program.cs.

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
      SQLiteFunction.RegisterFunction(typeof(MyCount));
      SQLiteFunction.RegisterFunction(typeof(MySequence));

      using (cnn = new SQLiteConnection())
      {
        TestCases tests = new TestCases();

        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off";
        cnn.Open();
        tests.Run(cnn);

        System.Windows.Forms.Application.Run(tests.frm);
      }

      System.IO.File.Delete("test.db3");
    }
  }
}







|










30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
      SQLiteFunction.RegisterFunction(typeof(MyCount));
      SQLiteFunction.RegisterFunction(typeof(MySequence));

      using (cnn = new SQLiteConnection())
      {
        TestCases tests = new TestCases();

        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off;UseUTF16Encoding=TRUE";
        cnn.Open();
        tests.Run(cnn);

        System.Windows.Forms.Application.Run(tests.frm);
      }

      System.IO.File.Delete("test.db3");
    }
  }
}