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


C# SqliteCommand.CreateParameter方法代码示例

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


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

示例1: ExportMethod


//.........这里部分代码省略.........
                            }
                        }
                    }


                    using (SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", _filename)))
                    {
                        dbcon.Open();

                        DbParameter par;
                        using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_SAVING, STR_SAVINGGEOCACHES, _gcList.Count, 0))
                        {
                            using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd2 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd3 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd4 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd5 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd6 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd7 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd8 = new SqliteCommand("", dbcon))
                            {
                                cmd.CommandText = "drop index CachesSmart";
                                cmd.ExecuteNonQuery();

                                cmd.CommandText = "insert into Caches (Code, Name, PlacedBy, Archived, CacheId, CacheType, Container, Country, Difficulty, Found, HasCorrected, HasUserNote, Latitude, LongHtm, Longitude, OwnerName, PlacedDate, ShortHtm, State, Terrain, UserFlag, IsOwner, LatOriginal, LonOriginal, Status, GcNote, IsPremium, FavPoints) values (@Code, @Name, @PlacedBy, @Archived, @CacheId, @CacheType, @Container, @Country, @Difficulty, @Found, @HasCorrected, @HasUserNote, @Latitude, @LongHtm, @Longitude, @OwnerName, @PlacedDate, @ShortHtm, @State, @Terrain, @UserFlag, @IsOwner, @LatOriginal, @LonOriginal, @Status, @GcNote, @IsPremium, @FavPoints)";
                                cmd2.CommandText = "insert into CacheMemo (Code, LongDescription, ShortDescription, Url, Hints, UserNote) values (@Code, @LongDescription, @ShortDescription, @Url, @Hints, @UserNote)";
                                cmd3.CommandText = "insert into Attributes (aCode, aId, aInc) values (@aCode, @aId, @aInc)";
                                cmd4.CommandText = "insert into LogMemo (lParent, lLogId, lText) values (@lParent, @lLogId, @lText)";
                                cmd5.CommandText = "insert into Logs (lParent, lLogId, lType, lBy, lDate, lLat, lLon, lEncoded, lownerid, lHasHtml, lIsowner, lTime) values (@lParent, @lLogId, @lType, @lBy, @lDate, @lLat, @lLon, @lEncoded, @lownerid, @lHasHtml, @lIsowner, @lTime)";
                                cmd6.CommandText = "insert into WayMemo (cParent, cCode, cComment, cUrl) values (@cParent, @cCode, @cComment, @cUrl)";
                                cmd7.CommandText = "insert into Waypoints (cParent, cCode, cPrefix, cName, cType, cLat, cLon, cByuser, cDate, cFlag, sB1) values (@cParent, @cCode, @cPrefix, @cName, @cType, @cLat, @cLon, @cByuser, @cDate, @cFlag, @sB1)";
                                cmd8.CommandText = "insert into Corrected (kCode, kBeforeLat, kBeforeLon, kAfterLat, kAfterLon) values (@kCode, @kBeforeLat, @kBeforeLon, @kAfterLat, @kAfterLon)";

                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kCode";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);

                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cParent";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cCode";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cPrefix";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
开发者ID:RH-Code,项目名称:GAPP,代码行数:67,代码来源:ExportAddOnGSAKDatabase.cs

示例2: ImportMethod

        protected override void ImportMethod()
        {
            System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
            using (Utils.ProgressBlock fixpr = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGDATA, 1, 0))
            {
                String connect = String.Format("data source=file:{0}", _filename);
                using (SqliteConnection dbcon = new SqliteConnection(connect))
                {

                    //System.Diagnostics.Debugger.Break();
                    logTypes.Add("Found it", 2);
                    logTypes.Add("Didn't find it", 3);
                    logTypes.Add("Write note", 4);
                    logTypes.Add("Archive", 5);
                    logTypes.Add("Needs Archived", 7);
                    logTypes.Add("Will Attend", 9);
                    logTypes.Add("Attended", 10);
                    logTypes.Add("Webcam Photo Taken", 11);
                    logTypes.Add("Unarchive", 12);
                    logTypes.Add("Temporarily Disable Listing", 22);
                    logTypes.Add("Enable Listing", 23);
                    logTypes.Add("Publish Listing", 24);
                    logTypes.Add("Retract Listing", 25);
                    logTypes.Add("Needs Maintenance", 45);
                    logTypes.Add("Owner Maintenance", 46);
                    logTypes.Add("Update Coordinates", 47);
                    logTypes.Add("Post Reviewer Note", 68);
                    logTypes.Add("Announcement", 74);
                    int index = 0;
                    int procStep = 0;

                    dbcon.Open();

                    SqliteCommand lookup = new SqliteCommand("select aId, aInc from attributes where aCode = @Code", dbcon);
                    lookup.CommandType = CommandType.Text;
                    DbParameter par = lookup.CreateParameter();
                    par.Direction = ParameterDirection.Input;
                    par.ParameterName = "@Code";
                    lookup.Parameters.Add(par);
                    lookup.Prepare();

                    SqliteCommand import = new SqliteCommand("select count(1) from caches", dbcon);
                    import.CommandType = CommandType.Text;


                    int gcCount = (int)(long)import.ExecuteScalar();
                    if (gcCount > 0)
                    {
                        using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGGEOCACHES, gcCount, 0))
                        {

                            bool isPremiumAvailable = false;
                            bool isFavPointAvailable = false;
                            bool isGCNoteAvailable = false;

                            try
                            {
                                import.CommandText = "select IsPremium from Caches limit 1";
                                using (SqliteDataReader checkdr = import.ExecuteReader())
                                {
                                    isPremiumAvailable = true;
                                }
                            }
                            catch
                            {
                            }

                            try
                            {
                                import.CommandText = "select FavPoints from Caches limit 1";
                                using (SqliteDataReader checkdr = import.ExecuteReader())
                                {
                                    isFavPointAvailable = true;
                                }
                            }
                            catch
                            {
                            }

                            try
                            {
                                import.CommandText = "select gcnote from Caches limit 1";
                                using (SqliteDataReader checkdr = import.ExecuteReader())
                                {
                                    isGCNoteAvailable = true;
                                }
                            }
                            catch
                            {
                            }

                            import.CommandText = "select caches.Code, Name, LastGPXDate, PlacedDate, Latitude, Longitude, Status, " +
                                "Archived, Country, State, CacheType, PlacedBy, OwnerName, OwnerId, Container, Terrain, Difficulty, ShortHTM" +
                                ", LongHTM, " +
                                string.Format("{0}", isPremiumAvailable? "IsPremium, ":"") +
                                " HasCorrected, LatOriginal, LonOriginal, UserFlag, Found, " +
                                string.Format("{0}", isFavPointAvailable? "FavPoints, ":"") +
                                " ShortDescription, LongDescription, Hints, Url, UserNote" +
                                string.Format("{0}", isGCNoteAvailable ? ", gcnote" : "") +
                                " from caches" +
//.........这里部分代码省略.........
开发者ID:RH-Code,项目名称:GAPP,代码行数:101,代码来源:ImportGSAK.cs

示例3: Save

        public bool Save(SqliteConnection dbcon, bool forceFullData)
        {
            bool result = true;
            using (Utils.ProgressBlock fixpr = new ProgressBlock(this, STR_SAVING, STR_SAVINGDATA, 1, 0))
            {
                if (dbcon != null)
                {
                    string[] custAttr = Core.Geocaches.CustomAttributes;
                    List<string> activeAttr = new List<string>();
                    using (SqliteCommand cmd = new SqliteCommand("select field_name from geocache_cfields", dbcon))
                    using (SqliteDataReader dr = cmd.ExecuteReader())
                    while (dr.Read())
                    {
                        activeAttr.Add(string.Format("{0}", dr["field_name"]));
                    }

                    foreach (string s in activeAttr)
                    {
                        if (!custAttr.Contains(s) && ColumnExists(dbcon, "geocache", string.Format("_{0}", s)))
                        {
                            //drop column not supported!
                        }
                    }
                    //geocache_cfields
                    using (SqliteCommand cmd = new SqliteCommand("delete from geocache_cfields", dbcon))
                        cmd.ExecuteNonQuery();
                    foreach (string s in custAttr)
                    {
                        if (!activeAttr.Contains(s))
                        {
                            using (SqliteCommand cmd = new SqliteCommand(string.Format("insert into geocache_cfields (field_name) values ('{0}')", s), dbcon))
                                cmd.ExecuteNonQuery();
                        }
                        if (!ColumnExists(dbcon, "geocache", string.Format("_{0}", s)))
                        {
                            using (SqliteCommand cmd = new SqliteCommand(string.Format("alter table geocache add _{0} text)", s), dbcon))
                                cmd.ExecuteNonQuery();
                        }
                    }

                    //delete geoacches that are not in the list anymore.
                    string[] c = (from string a in _geocachesInDB.Keys select a).ToArray();
                    using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                        for (int i = 0; i < c.Length; i++)
                        {
                            if (Utils.DataAccess.GetGeocache(Core.Geocaches, c[i]) == null)
                            {
                                cmd.CommandText = string.Format("delete from geocache where code='{0}'", c[i]);
                                cmd.ExecuteNonQuery();
                                _geocachesInDB.Remove(c[i]);
                            }
                        }

                    //reset selection
                    using (SqliteCommand cmd = new SqliteCommand("update geocache set selected=0", dbcon))
                        cmd.ExecuteNonQuery();

                    //now get all the selected and data changed geocaches
                    List<Framework.Data.Geocache> gclist = (from Framework.Data.Geocache wp in Core.Geocaches
                                                            where wp.Selected || !wp.Saved
                                                            select wp).ToList();
                    if (gclist.Count > 0)
                    {
                        using (Utils.ProgressBlock progress = new ProgressBlock(this, STR_SAVING, STR_SAVINGGEOCACHES, gclist.Count, 0))
                        {
                            string updateSqlFull = "update geocache set [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] where [email protected]";
                            string insertSqlFull = "insert into geocache (id, code, name, datafromdate, lat, lon, disttocent, angletocent, available, archived, country, state, cachetype, placedby, owner, ownerid, container, terrain, difficulty, shortdescr, shortdescrhtml, longdescr, longdescrhtml, encodedhints, url, memberonly, customcoords, attrids, favorites, selected, municipality, city, customlat, customlon, notes, publiceddate, personalnote, flagged, found, locked) values (@id, @code, @name, @datafromdate, @lat, @lon, @disttocent, @angletocent, @available, @archived, @country, @state, @cachetype, @placedby, @owner, @ownerid, @container, @terrain, @difficulty, @shortdescr, @shortdescrhtml, @longdescr, @longdescrhtml, @encodedhints, @url, @memberonly, @customcoords, @attrids, @favorites, @selected, @municipality, @city, @customlat, @customlon, @notes, @publiceddate, @personalnote, @flagged, @found, @locked)";

                            string updateSqlShort = "update geocache set [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] where [email protected]";
                            string insertSqlShort = "insert into geocache (id, code, name, datafromdate, lat, lon, disttocent, angletocent, available, archived, country, state, cachetype, placedby, owner, ownerid, container, terrain, difficulty, encodedhints, url, memberonly, customcoords, attrids, favorites, selected, municipality, city, customlat, customlon, notes, publiceddate, personalnote, flagged, found, locked) values (@id, @code, @name, @datafromdate, @lat, @lon, @disttocent, @angletocent, @available, @archived, @country, @state, @cachetype, @placedby, @owner, @ownerid, @container, @terrain, @difficulty, @encodedhints, @url, @memberonly, @customcoords, @attrids, @favorites, @selected, @municipality, @city, @customlat, @customlon, @notes, @publiceddate, @personalnote, @flagged, @found, @locked)";

                            using (SqliteCommand cmd = new SqliteCommand("",dbcon))
                            {
                                cmd.CommandType = CommandType.Text;
                                DbParameter par = cmd.CreateParameter();
                                par.ParameterName = "@id";
                                par.DbType = DbType.String;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@code";
                                par.DbType = DbType.String;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@name";
                                par.DbType = DbType.String;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@datafromdate";
                                par.DbType = DbType.String;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@lat";
                                par.DbType = DbType.Double;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@lon";
                                par.DbType = DbType.Double;
                                cmd.Parameters.Add(par);
                                par = cmd.CreateParameter();
                                par.ParameterName = "@disttocent";
//.........这里部分代码省略.........
开发者ID:RH-Code,项目名称:GAPP,代码行数:101,代码来源:InternalStorage.cs

示例4: ExportToGDAK


//.........这里部分代码省略.........
                                foreach (string s in SQLCREATEDBINDEXES)
                                {
                                    cmd.CommandText = s;
                                    cmd.ExecuteNonQuery();
                                }
                                foreach (string s in SQLCREATEDBTRIGGERS)
                                {
                                    cmd.CommandText = s;
                                    cmd.ExecuteNonQuery();
                                }
                                cmd.CommandText = "PRAGMA user_version = 5003";
                                cmd.ExecuteNonQuery();
                            }

                            DbParameter par;
                            using (Utils.ProgressBlock progress = new Utils.ProgressBlock("SavingGeocaches", gcList.Count, 0))
                            {
                                using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd2 = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd3 = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd4 = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd5 = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd6 = new SqliteCommand("", dbcon))
                                using (SqliteCommand cmd7 = new SqliteCommand("", dbcon))
                                {
                                    cmd.CommandText = "insert into Caches (Code, Name, PlacedBy, Archived, CacheId, CacheType, Container, Country, Difficulty, Found, HasCorrected, HasUserNote, Latitude, LongHtm, Longitude, OwnerName, PlacedDate, ShortHtm, State, Terrain, UserFlag, IsOwner, LatOriginal, LonOriginal, Status, GcNote, IsPremium, FavPoints, IsLite) values (@Code, @Name, @PlacedBy, @Archived, @CacheId, @CacheType, @Container, @Country, @Difficulty, @Found, @HasCorrected, @HasUserNote, @Latitude, @LongHtm, @Longitude, @OwnerName, @PlacedDate, @ShortHtm, @State, @Terrain, @UserFlag, @IsOwner, @LatOriginal, @LonOriginal, @Status, @GcNote, @IsPremium, @FavPoints, @IsLite)";
                                    cmd2.CommandText = "insert into CacheMemo (Code, LongDescription, ShortDescription, Url, Hints, UserNote) values (@Code, @LongDescription, @ShortDescription, @Url, @Hints, @UserNote)";
                                    cmd3.CommandText = "insert into Attributes (aCode, aId, aInc) values (@aCode, @aId, @aInc)";
                                    cmd4.CommandText = "insert into LogMemo (lParent, lLogId, lText) values (@lParent, @lLogId, @lText)";
                                    cmd5.CommandText = "insert into Logs (lParent, lLogId, lType, lBy, lDate, lLat, lLon, lEncoded, lownerid, lHasHtml, lIsowner, lTime) values (@lParent, @lLogId, @lType, @lBy, @lDate, @lLat, @lLon, @lEncoded, @lownerid, @lHasHtml, @lIsowner, @lTime)";
                                    cmd6.CommandText = "insert into WayMemo (cParent, cCode, cComment, cUrl) values (@cParent, @cCode, @cComment, @cUrl)";
                                    cmd7.CommandText = "insert into Waypoints (cParent, cCode, cPrefix, cName, cType, cLat, cLon, cByuser, cDate, cFlag, sB1) values (@cParent, @cCode, @cPrefix, @cName, @cType, @cLat, @cLon, @cByuser, @cDate, @cFlag, @sB1)";

                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cParent";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cCode";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cPrefix";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cName";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cType";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cLat";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cLon";
                                    par.DbType = DbType.String;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
                                    par.ParameterName = "@cByuser";
                                    par.DbType = DbType.Boolean;
                                    cmd7.Parameters.Add(par);
                                    par = cmd7.CreateParameter();
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:67,代码来源:Export.cs

示例5: ExportToFile

        public static void ExportToFile(string filename, List<Core.Data.Geocache> gcList)
        {
            try
            {
                DateTime nextUpdate = DateTime.Now.AddSeconds(1);
                using (Utils.ProgressBlock fixscr = new Utils.ProgressBlock("ExportingiGeoKnife", "CreatingFile", 1, 0, true))
                {
                    System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
                    logTypes.Add(2, "Found it");
                    logTypes.Add(3, "Didn't find it");
                    logTypes.Add(4, "Write note");
                    logTypes.Add(5, "Archive");
                    logTypes.Add(7, "Needs Archived");
                    logTypes.Add(9, "Will Attend");
                    logTypes.Add(10, "Attended");
                    logTypes.Add(11, "Webcam Photo Taken");
                    logTypes.Add(12, "Unarchive");
                    logTypes.Add(22, "Temporarily Disable Listing");
                    logTypes.Add(23, "Enable Listing");
                    logTypes.Add(24, "Publish Listing");
                    logTypes.Add(25, "Retract Listing");
                    logTypes.Add(45, "Needs Maintenance");
                    logTypes.Add(46, "Owner Maintenance");
                    logTypes.Add(47, "Update Coordinates");
                    logTypes.Add(68, "Post Reviewer Note");
                    logTypes.Add(74, "Announcement");

                    if (System.IO.File.Exists(filename))
                    {
                        System.IO.File.Delete(filename);
                    }

                    Utils.ResourceHelper.SaveToFile("/iGeoKnife/sqlite.db3", filename, true);

                    using (SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", filename)))
                    {
                        dbcon.Open();

                        DbParameter par;
                        using (Utils.ProgressBlock progress = new Utils.ProgressBlock("ExportingiGeoKnife", "SavingGeocaches", gcList.Count, 0, true))
                        {
                            using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd2 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd3 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd4 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd5 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd6 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd7 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd8 = new SqliteCommand("", dbcon))
                            {
                                cmd.CommandText = "drop index CachesSmart";
                                cmd.ExecuteNonQuery();

                                cmd.CommandText = "insert into Caches (Code, Name, PlacedBy, Archived, CacheId, CacheType, Container, Country, Difficulty, Found, HasCorrected, HasUserNote, Latitude, LongHtm, Longitude, OwnerName, PlacedDate, ShortHtm, State, Terrain, UserFlag, IsOwner, LatOriginal, LonOriginal, Status, GcNote, IsPremium, FavPoints) values (@Code, @Name, @PlacedBy, @Archived, @CacheId, @CacheType, @Container, @Country, @Difficulty, @Found, @HasCorrected, @HasUserNote, @Latitude, @LongHtm, @Longitude, @OwnerName, @PlacedDate, @ShortHtm, @State, @Terrain, @UserFlag, @IsOwner, @LatOriginal, @LonOriginal, @Status, @GcNote, @IsPremium, @FavPoints)";
                                cmd2.CommandText = "insert into CacheMemo (Code, LongDescription, ShortDescription, Url, Hints, UserNote) values (@Code, @LongDescription, @ShortDescription, @Url, @Hints, @UserNote)";
                                cmd3.CommandText = "insert into Attributes (aCode, aId, aInc) values (@aCode, @aId, @aInc)";
                                cmd4.CommandText = "insert into LogMemo (lParent, lLogId, lText) values (@lParent, @lLogId, @lText)";
                                cmd5.CommandText = "insert into Logs (lParent, lLogId, lType, lBy, lDate, lLat, lLon, lEncoded, lownerid, lHasHtml, lIsowner, lTime) values (@lParent, @lLogId, @lType, @lBy, @lDate, @lLat, @lLon, @lEncoded, @lownerid, @lHasHtml, @lIsowner, @lTime)";
                                cmd6.CommandText = "insert into WayMemo (cParent, cCode, cComment, cUrl) values (@cParent, @cCode, @cComment, @cUrl)";
                                cmd7.CommandText = "insert into Waypoints (cParent, cCode, cPrefix, cName, cType, cLat, cLon, cByuser, cDate, cFlag, sB1) values (@cParent, @cCode, @cPrefix, @cName, @cType, @cLat, @cLon, @cByuser, @cDate, @cFlag, @sB1)";
                                cmd8.CommandText = "insert into Corrected (kCode, kBeforeLat, kBeforeLon, kAfterLat, kAfterLon) values (@kCode, @kBeforeLat, @kBeforeLon, @kAfterLat, @kAfterLon)";

                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kCode";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);

                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cParent";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cCode";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cPrefix";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cName";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
//.........这里部分代码省略.........
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:101,代码来源:Export.cs

示例6: Import

        private static bool Import(Database database, string filename)
        {
            System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
            String connect = String.Format("data source=file:{0}", filename);
            using (SqliteConnection dbcon = new SqliteConnection(connect))
            {

                //System.Diagnostics.Debugger.Break();
                logTypes.Add("Found it", 2);
                logTypes.Add("Didn't find it", 3);
                logTypes.Add("Write note", 4);
                logTypes.Add("Archive", 5);
                logTypes.Add("Needs Archived", 7);
                logTypes.Add("Will Attend", 9);
                logTypes.Add("Attended", 10);
                logTypes.Add("Webcam Photo Taken", 11);
                logTypes.Add("Unarchive", 12);
                logTypes.Add("Temporarily Disable Listing", 22);
                logTypes.Add("Enable Listing", 23);
                logTypes.Add("Publish Listing", 24);
                logTypes.Add("Retract Listing", 25);
                logTypes.Add("Needs Maintenance", 45);
                logTypes.Add("Owner Maintenance", 46);
                logTypes.Add("Update Coordinates", 47);
                logTypes.Add("Post Reviewer Note", 68);
                logTypes.Add("Announcement", 74);

                dbcon.Open();

                SqliteCommand lookup = new SqliteCommand("select aId, aInc from attributes where aCode = @Code", dbcon);
                lookup.CommandType = CommandType.Text;
                DbParameter par = lookup.CreateParameter();
                par.Direction = ParameterDirection.Input;
                par.ParameterName = "@Code";
                lookup.Parameters.Add(par);
                lookup.Prepare();

                SqliteCommand import = new SqliteCommand("select count(1) from caches", dbcon);
                import.CommandType = CommandType.Text;

                int index = 0;
                int gcCount = (int)(long)import.ExecuteScalar();
                if (gcCount > 0)
                {
                    DateTime progShow = DateTime.Now.AddSeconds(1);
                    using (Utils.ProgressBlock prog = new ProgressBlock("Import GSAK database", "Importing...", 1, 0))
                    {
                        bool isPremiumAvailable = false;
                        bool isFavPointAvailable = false;
                        bool isGCNoteAvailable = false;

                        try
                        {
                            import.CommandText = "select IsPremium from Caches limit 1";
                            using (SqliteDataReader checkdr = import.ExecuteReader())
                            {
                                isPremiumAvailable = true;
                            }
                        }
                        catch
                        {
                        }

                        try
                        {
                            import.CommandText = "select FavPoints from Caches limit 1";
                            using (SqliteDataReader checkdr = import.ExecuteReader())
                            {
                                isFavPointAvailable = true;
                            }
                        }
                        catch
                        {
                        }

                        try
                        {
                            import.CommandText = "select gcnote from Caches limit 1";
                            using (SqliteDataReader checkdr = import.ExecuteReader())
                            {
                                isGCNoteAvailable = true;
                            }
                        }
                        catch
                        {
                        }

                        import.CommandText = "select caches.Code, Name, LastGPXDate, PlacedDate, Latitude, Longitude, Status, " +
                            "Archived, Country, State, CacheType, PlacedBy, OwnerName, OwnerId, Container, Terrain, Difficulty, ShortHTM" +
                            ", LongHTM, " +
                            string.Format("{0}", isPremiumAvailable ? "IsPremium, " : "") +
                            " HasCorrected, LatOriginal, LonOriginal, UserFlag, Found, " +
                            string.Format("{0}", isFavPointAvailable ? "FavPoints, " : "") +
                            " ShortDescription, LongDescription, Hints, Url, UserNote" +
                            string.Format("{0}", isGCNoteAvailable ? ", gcnote" : "") +
                            " from caches" +
                            " inner join cachememo on cachememo.code = caches.code";

                        SqliteDataReader dr = import.ExecuteReader();

//.........这里部分代码省略.........
开发者ID:patl12345,项目名称:GAPP,代码行数:101,代码来源:Importer.cs


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