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


C# SQLiteConnection.Close方法代码示例

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


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

示例1: execute

 internal static void execute(string queryString)
 {
     using (var conn = new SQLiteConnection(SQLite.connString)) {
         conn.Open();
         using (SQLiteCommand cmd = new SQLiteCommand(queryString, conn)) {
             cmd.ExecuteNonQuery();
             conn.Close();
         }
     }
 }
开发者ID:Cazzar,项目名称:MCForge-MCLawl,代码行数:10,代码来源:SQLite.cs

示例2: fill

 internal static void fill(string queryString, DataTable toReturn)
 {
     using (var conn = new SQLiteConnection(SQLite.connString)) {
         conn.Open();
         using (SQLiteDataAdapter da = new SQLiteDataAdapter(queryString, conn)) {
             da.Fill(toReturn);
         }
         conn.Close();
     }
 }
开发者ID:Cazzar,项目名称:MCForge-MCLawl,代码行数:10,代码来源:SQLite.cs

示例3: CreateTables

 private void CreateTables()
 {
     using (var conn = new SQLiteConnection(_platform, _dbPath))
     {
         conn.CreateTable<Image>();
         conn.CreateTable<Position>();
         conn.CreateTable<Station>();
         conn.CreateTable<FavoriteTrainPath>();
         conn.Close();
     }
 }
开发者ID:DrNorton,项目名称:TrineTimeTable,代码行数:11,代码来源:SqliteContext.cs

示例4: xeqSQL

 void xeqSQL(string script)
 {
     Devart.Data.SQLite.SQLiteConnection sqLiteConnection1 = new SQLiteConnection();
     sqLiteConnection1.ConnectionString = myConfig.connstr;
     SQLiteCommand sqLiteCommand1 = new SQLiteCommand();
     sqLiteCommand1.CommandText = script;
     sqLiteCommand1.CommandType = CommandType.Text;
     sqLiteCommand1.Connection = sqLiteConnection1;
     sqLiteConnection1.Open();
     sqLiteCommand1.ExecuteNonQuery();
     sqLiteConnection1.Close();
 }
开发者ID:rjreeves,项目名称:Vectra,代码行数:12,代码来源:ReceiptAndAdjReportForm.cs

示例5: DeleteAll

        public void DeleteAll()
        {
            var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");

            using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
            {
                conn.DropTable<Student>();
                conn.CreateTable<Student>();
                conn.Dispose();
                conn.Close();
            }
        }
开发者ID:Adaok,项目名称:SqLite_Windows10,代码行数:12,代码来源:Database.cs

示例6: AddMeetingsDB

        public static void AddMeetingsDB(ObservableCollection<MobileMeetingProject.EsEngine.AttendeeWrapper> Attendees, string EventId)
        {
            DeleteMeetingsDB(EventId);
            foreach (AttendeeWrapper TempAtt in Attendees)
            {
                foreach (MeetingParticipant ThisMeeting in TempAtt.Meetings)
                {
                    SQLiteConnection sqlCon = new SQLiteConnection(Utilities.GetConnectionString());
                    SQLiteCommand sqlCmd = new SQLiteCommand("INSERT INTO Meetings(MeetingId,EventId,Id,Name,CompanyName,Role,Status,IsWalkin,JobTitle,AllocatedTable,"+
                                                             "AttendeeWantId,StartTime,EndTime,IsPrimary,TableName) VALUES(@MeetingId,@EventId,@Id,@Name,@CompanyName,@Role,"+
                                                             "@Status,@IsWalkin,@JobTitle,@AllocatedTable,@AttendeeWantId,@StartTime,@EndTime,@IsPrimary,@TableName)", sqlCon);

                    sqlCmd.Parameters.AddWithValue("@MeetingId", ThisMeeting.MeetingId);
                    sqlCmd.Parameters.AddWithValue("@EventId", EventId);
                    sqlCmd.Parameters.AddWithValue("@Id", ThisMeeting.Id);
                    sqlCmd.Parameters.AddWithValue("@Name", ThisMeeting.Name);
                    sqlCmd.Parameters.AddWithValue("@CompanyName", ThisMeeting.CompanyName);
                    sqlCmd.Parameters.AddWithValue("@Role", ThisMeeting.Role);
                    sqlCmd.Parameters.AddWithValue("@Status", ThisMeeting.Status);
                    sqlCmd.Parameters.AddWithValue("@IsWalkin", ThisMeeting.IsWalkin);
                    sqlCmd.Parameters.AddWithValue("@JobTitle", ThisMeeting.JobTitle);
                    sqlCmd.Parameters.AddWithValue("@AllocatedTable", ThisMeeting.AllocatedTable);
                    sqlCmd.Parameters.AddWithValue("@AttendeeWantId", TempAtt.ThisAttendee.Id);
                    sqlCmd.Parameters.AddWithValue("@StartTime", ThisMeeting.MeetingSlotStartTime);
                    sqlCmd.Parameters.AddWithValue("@EndTime", ThisMeeting.MeetingSlotEndTime);
                    sqlCmd.Parameters.AddWithValue("@IsPrimary", ThisMeeting.IsPrimary);
                    sqlCmd.Parameters.AddWithValue("@TableName", ThisMeeting.TableName);

                    try
                    {
                        sqlCon.Open();
                        int RowsAffected = sqlCmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        string Message = ex.Message;
                    }
                    finally
                    {
                        sqlCon.Close();
                    }
                }
            }
        }
开发者ID:faisalkhanzada,项目名称:MobileMeetingProject,代码行数:44,代码来源:MeetingsHelper.cs

示例7: AutoGuid_HasGuid

        public void AutoGuid_HasGuid()
        {
            var db = new SQLiteConnection(TestPath.GetTempFileName());
            db.CreateTable<TestObj>(CreateFlags.AutoIncPK);

            var guid1 = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623");
            var guid2 = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6");

            var obj1 = new TestObj() { Id = guid1, Text = "First Guid Object" };
            var obj2 = new TestObj() { Id = guid2, Text = "Second Guid Object" };

            db.Insert(obj1);
            db.Insert(obj2);

            Assert.AreEqual(guid1, obj1.Id);
            Assert.AreEqual(guid2, obj2.Id);

            db.Close();
        }
开发者ID:ChlorophyllVision,项目名称:sqlite-net,代码行数:19,代码来源:GuidTests.cs

示例8: AutoGuid_EmptyGuid

        public void AutoGuid_EmptyGuid()
        {
            var db = new SQLiteConnection(TestPath.GetTempFileName());
            db.CreateTable<TestObj>(CreateFlags.AutoIncPK);

            var obj1 = new TestObj() { Text = "First Guid Object" };
            var obj2 = new TestObj() { Text = "Second Guid Object" };

            Assert.AreEqual(Guid.Empty, obj1.Id);
            Assert.AreEqual(Guid.Empty, obj2.Id);

            db.Insert(obj1);
            db.Insert(obj2);

            Assert.AreNotEqual(Guid.Empty, obj1.Id);
            Assert.AreNotEqual(Guid.Empty, obj2.Id);
            Assert.AreNotEqual(obj1.Id, obj2.Id);

            db.Close();
        }
开发者ID:ChlorophyllVision,项目名称:sqlite-net,代码行数:20,代码来源:GuidTests.cs

示例9: ExecuteScalar

            /// <summary>
            /// Shortcut to ExecuteScalar with Sql Statement embedded params and object[] param values
            /// </summary>
            /// <param name="connectionString">SQLite Connection String</param>
            /// <param name="commandText">SQL statment with embedded "@param" style parameters</param>
            /// <param name="paramList">object[] array of param values</param>
            /// <returns></returns>
            public static object ExecuteScalar(string connectionString, string commandText, params  object[] paramList)
            {
                SQLiteConnection cn = new SQLiteConnection(connectionString);
                SQLiteCommand cmd = cn.CreateCommand();
                cmd.CommandText = commandText;
                AttachParameters(cmd, commandText, paramList);
                if (cn.State == ConnectionState.Closed)
                    cn.Open();
                object result = cmd.ExecuteScalar();
                cmd.Dispose();
                cn.Close();

                return result;
            }
开发者ID:x55756016,项目名称:TMReminder,代码行数:21,代码来源:SQLiteHelper.cs

示例10: openFile


//.........这里部分代码省略.........
                                        file.cardColSize = 5;
                                    }
                                    try
                                    {

                                        file.numCardsToPrint = int.Parse(reader["numcardstoprint"].ToString());
                                    }
                                    catch
                                    {
                                        file.numCardsToPrint = 1;
                                    }
                                    try
                                    {
                                        file.numCardsPerPage = int.Parse(reader["numcardsperpage"].ToString());
                                    }
                                    catch
                                    {
                                        file.numCardsPerPage = 1;
                                    }
                                    try
                                    {
                                        printTitle = int.Parse(reader["printTitle"].ToString());
                                    }
                                    catch
                                    {
                                        printTitle = 0;
                                    }

                                    if (printTitle >= 1)
                                    {
                                        file.printTitle = true;
                                    }
                                    else
                                    {
                                        file.printTitle = false;
                                    }

                                    try
                                    {
                                        printFreeSpace = int.Parse(reader["printFreeSpace"].ToString());
                                    }
                                    catch
                                    {
                                        printFreeSpace = 0;
                                    }

                                    if (printFreeSpace >= 1)
                                    {
                                        file.printFreeSpace = true;
                                    }
                                    else
                                    {
                                        file.printFreeSpace = false;
                                    }
                                }
                            }
                        }
                        catch
                        {
                            file.cardColSize = file.cardRowSize = 5;  //Set default values so we don't get divide by 0
                        }

                        cmd.CommandText = "SELECT * FROM 'wordlist'";
                        try
                        {
                            using (DbDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    try
                                    {
                                        file.wordList.Add(reader["word"].ToString());
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }

                        configdb.Close();
                    }

                }
            }
            catch
            {

            }

            finally
            {
                Cursor.Current = Cursors.Default;

            }
            return (file);
        }
开发者ID:xyzio,项目名称:bingowords,代码行数:101,代码来源:BingoFuncs.cs

示例11: GetMeetings

        public static ObservableCollection<MeetingParticipant> GetMeetings(string EventId, string AttendeeWantId)
        {
            ObservableCollection<MeetingParticipant> Meetings = new ObservableCollection<MeetingParticipant>();

            SQLiteConnection sqlCon = new SQLiteConnection(Utilities.GetConnectionString());
            SQLiteCommand sqlCmd = new SQLiteCommand("SELECT * FROM Meetings WHERE EventId = @EventId AND AttendeeWantId = @AttendeeWantId", sqlCon);

            sqlCmd.Parameters.AddWithValue("@EventId", EventId);
            sqlCmd.Parameters.AddWithValue("@AttendeeWantId", AttendeeWantId);

            try
            {
                sqlCon.Open();

                SQLiteDataReader reader = sqlCmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        MeetingParticipant ThisMeeting = new MeetingParticipant();

                        ThisMeeting.MeetingId = reader.GetInt32(0);
                        ThisMeeting.Id = reader.GetString(2);
                        ThisMeeting.Name = reader[3] != DBNull.Value ? reader.GetString(3) : string.Empty;
                        ThisMeeting.CompanyName = reader[4] != DBNull.Value ? reader.GetString(4) : string.Empty;
                        ThisMeeting.Role = reader[5] != DBNull.Value ? reader.GetString(5) : string.Empty;
                        ThisMeeting.Status = reader[6] != DBNull.Value ? reader.GetString(6) : string.Empty;
                        ThisMeeting.IsWalkin = reader.GetBoolean(7);
                        ThisMeeting.JobTitle = reader[8] != DBNull.Value ? reader.GetString(8) : string.Empty;
                        ThisMeeting.AllocatedTable = reader[9] != DBNull.Value ? reader.GetString(9) : string.Empty;
                        ThisMeeting.MeetingSlotStartTime = reader.GetDateTime(11);
                        ThisMeeting.MeetingSlotEndTime = reader.GetDateTime(12);
                        ThisMeeting.IsPrimary = reader.GetBoolean(13);
                        ThisMeeting.TableName = reader.GetString(14);

                        Meetings.Add(ThisMeeting);
                    }
                }
            }
            catch (Exception ex)
            {
                string Meesage = ex.Message;
            }
            finally
            {
                sqlCon.Close();
            }

            return Meetings;
        }
开发者ID:faisalkhanzada,项目名称:MobileMeetingProject,代码行数:51,代码来源:MeetingsHelper.cs

示例12: writeFile

        public bool writeFile(BingoWordFile file)
        {
            if (file.filePath.EndsWith(".bwf") == false)
            {
                file.filePath += ".bwf";
            } //Bingo word file

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                using (DbConnection configdb = new SQLiteConnection("Data Source=" + file.filePath))
                {
                    using (DbCommand cmd = configdb.CreateCommand())
                    {
                        //open the connection
                        configdb.Open();

                        try
                        {
                            cmd.CommandText = "DROP TABLE info";
                            cmd.ExecuteNonQuery();
                        }
                        catch
                        {

                        }
                        try
                        {
                            cmd.CommandText = "DROP TABLE wordlist";
                            cmd.ExecuteNonQuery();
                        }
                        catch
                        {

                        }

                        try
                        {
                            int freeSpacePrint = file.printFreeSpaceToInt();
                            int titlePrint = file.printTitleToInt();

                            cmd.CommandText = "CREATE TABLE info (cardtitletext TEXT, cardfreespacetext TEXT, cardrowsize TEXT, cardcolsize TEXT, numcardstoprint TEXT, numcardsperpage TEXT, printTitle TEXT, printFreeSpace TEXT)";
                            cmd.ExecuteNonQuery();

                            cmd.CommandText = "INSERT into info VALUES ('" + file.cardTitleText + "','" + file.cardFreeSpaceText + "','" + file.cardRowSize.ToString() + "', '" + file.cardColSize.ToString() + "', '" + file.numCardsToPrint.ToString() + "', '" + file.numCardsPerPage.ToString() + "', '" + titlePrint.ToString() + "', '" + freeSpacePrint.ToString() + "')";
                            cmd.ExecuteNonQuery();
                        }
                        catch
                        {
                        }

                        try
                        {
                            cmd.CommandText = "CREATE TABLE wordlist (word TEXT)";
                            cmd.ExecuteNonQuery();

                            foreach (string item in file.wordList)
                            {
                                cmd.CommandText = "INSERT into wordlist VALUES ('" + item + "')";
                                cmd.ExecuteNonQuery();
                            }

                        }

                        catch
                        {

                        }

                        try
                        {
                            configdb.Close();
                        }
                        catch
                        {
                        }
                    }

                }
            }
            catch
            {

            }

            finally
            {

                Cursor.Current = Cursors.Default;
            }

            return (true);
        }
开发者ID:xyzio,项目名称:bingowords,代码行数:94,代码来源:BingoFuncs.cs

示例13: ExecuteDataSet

            /// <summary>
            /// Shortcut method to execute dataset from SQL Statement and object[] arrray of parameter values
            /// </summary>
            /// <param name="connectionString">SQLite Connection string</param>
            /// <param name="commandText">SQL Statement with embedded "@param" style parameter names</param>
            /// <param name="paramList">object[] array of parameter values</param>
            /// <returns></returns>
            public static DataSet ExecuteDataSet(string connectionString, string commandText, object[] paramList)
            {
                SQLiteConnection cn = new SQLiteConnection(connectionString);
                SQLiteCommand cmd = cn.CreateCommand();

                cmd.CommandText = commandText;
                if (paramList != null)
                {
                    AttachParameters(cmd, commandText, paramList);
                }
                DataSet ds = new DataSet();
                if (cn.State == ConnectionState.Closed)
                    cn.Open();
                SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                da.Fill(ds);
                da.Dispose();
                cmd.Dispose();
                cn.Close();
                return ds;
            }
开发者ID:x55756016,项目名称:TMReminder,代码行数:27,代码来源:SQLiteHelper.cs

示例14: setRequestedDataType


//.........这里部分代码省略.........
                                                ee = CombineEvents(handle, entry, counterPart);

                                            }
                                            // else add handle to the handles list.
                                            //(irrespective of whether a 560 or 567 event occurs 1st record it)
                                            else
                                            {
                                                if (entry.InstanceId == 560 && !"".Equals(getFileName(entry.Message)))
                                                {

                                                    handleToEvent.Add(handle, entry);
                                                    //make the action as blank as this is the place where handle was granted. no action has taken place.
                                                    handleToAction.Add(handle, "");
                                                    // increment count
                                                    handleToCount.TryGetValue(handle,out count);
                                                    count++;
                                                    //handleToCount[handle] = count;
                                                    handleToCount.Add(handle, count);

                                                    //TODO: removed for removing client user
                                                    //NEW addition for client side file access:
                                                    //since 567 is not logged we put 560 event caused by client in the tree
                                                    /*if (fromClient(entry))
                                                    {
                                                        ee = new EventEntry(entry);
                                                    }*/
                                                }
                                            }
                                        }
                                    }
                                    //TODO: can see some 562 entries without their 560 in the log. Handle them by ignore them ?
                                    // if it is a remove
                                    else if (entry.InstanceId == 562)
                                    {
                                        count = 0;
                                        int handle = GetHandle(entry);
                                        if (handle != 0)
                                        {
                                            try
                                            {
                                                if (handleToCount[handle] == 0)
                                                {
                                                    handleToEvent.Remove(handle);
                                                    handleToCount.Remove(handle);
                                                    handleToAction.Remove(handle);
                                                }
                                                else
                                                {
                                                    count--;
                                                    handleToCount[handle] = count;
                                                }
                                            }
                                            catch (KeyNotFoundException)
                                            {
                                            }
                                        }
                                    }
                                    //add event in the file tree
                                    if (ee != null)
                                    {
                                        //currently not used
                                        events.Add(ee);

                                        //add the new entries to the db
                                        insertData(ee, comm);
                                    }

                                }
                                //else ignore the event altogether.
                                else
                                {
                                    continue;
                                }

                            }
                            tran.Commit();
                        }
                    }
                    catch (SQLiteException)
                    {
                        //MessageBox.Show("Insert Data Failed", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                conn.Close();
            }

            //TODO: put this at the bottom.. so that entries are not written twice.
            myEventLog.EntryWritten += new EntryWrittenEventHandler(myEventLog_EntryWrittenDb);
            myEventLog.EnableRaisingEvents = true;

            //TODO: add code to read from the log file. Compare the date with the latest time stamp. If the entry is new enter in db and update the screen.
            // other data structs like handleToEvent etc also have to be maintained but since the kernel wont log any actions with handle id it needs to be
            // decided what action has to be taken.

            //Code to add a watcher to the file which is being written to by the kernel.
            //Added a component in File overview which takes care of changes. Just need to make sure that can read entries and insert them into db before nw
            //accesses are done.

            return events;
        }
开发者ID:tkhurana,项目名称:File-Access-Monitor,代码行数:101,代码来源:EventLogger.cs

示例15: loadTableSchema

 //================================================================================================================================================================
 private DataTable loadTableSchema(string source, string[] restrictions, string schema, string name)
 {
     SQLiteConnection DBConnection = new SQLiteConnection(source);
     DBConnection.Open();
     DataTable dt = DBConnection.GetSchema(schema, restrictions);
     dt.TableName = name;
     DBConnection.Close();
     return dt;
 }
开发者ID:Miktor,项目名称:pub,代码行数:10,代码来源:Form1.cs


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