当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteConnection.LoadExtension方法代码示例

本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.LoadExtension方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.LoadExtension方法的具体用法?C# SQLiteConnection.LoadExtension怎么用?C# SQLiteConnection.LoadExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SQLite.SQLiteConnection的用法示例。


在下文中一共展示了SQLiteConnection.LoadExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        /// <summary>
        /// Loads mod_spatialite.dll on the given connection
        /// </summary>
        public static void Load(SQLiteConnection conn)
        {
            lock (Lock)
            {
                //Need to work out where the file is and add it to the path so it can load all the other dlls too
                if (!_haveSetPath)
                {
                    var spatialitePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), (Environment.Is64BitProcess ? "x64" : "x86"), "spatialite");

                    Environment.SetEnvironmentVariable("PATH", spatialitePath + ";" + Environment.GetEnvironmentVariable("PATH"));

                    _haveSetPath = true;
                }
            }

            conn.LoadExtension("mod_spatialite.dll");
        }
开发者ID:bradh,项目名称:SpatialiteSharp,代码行数:20,代码来源:SpatialiteLoader.cs

示例2: Main

        static void Main(string[] args)
        {
            string mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-amd64";

            if (is64bitProcess())
            {
                Console.WriteLine("64bit process");
                mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-amd64";
            }
            else if(is32bitProcess())
            {
                Console.WriteLine("32bit process");
                mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-x86";
            }

            //using relative path, cannot use absolute path, dll load will fail
            //string mod_spatialite_dllPath = @"mod_spatialite-4.3.0a-win-amd64\mod_spatialite";
            string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine) + ";" + mod_spatialite_folderPath;
            Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.Process);

            string sqlitePath = "_BCC_replication.sqlite";

            //select 'geometry::STGeomFromWKB(0x' || hex(ST_AsBinary(geometry)) || ', 28356) ' as geometry2  from qpp_airport_ols;
            string sqliteConnectionString = getSqliteV3ConnectionString(sqlitePath);

            using (var sqliteConnection = new SQLiteConnection(sqliteConnectionString))
            {
                sqliteConnection.Open();
                Console.WriteLine("Load-ing mod_spatialite");
                string mod_spatialite_dllPath = mod_spatialite_folderPath + @"\mod_spatialite";
                sqliteConnection.LoadExtension(mod_spatialite_dllPath);
                Console.WriteLine("Load-ed mod_spatialite");
                sqliteConnection.Execute("update qpp_airport_ols set lga_code = 111122 where ogc_fid = 2;");
            }

            Console.ReadLine();
        }
开发者ID:lydonchandra,项目名称:TestSpatialite,代码行数:37,代码来源:Program.cs


注:本文中的System.Data.SQLite.SQLiteConnection.LoadExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。