當前位置: 首頁>>代碼示例>>C#>>正文


C# MsSqlDbConnectionManager.CloseConnection方法代碼示例

本文整理匯總了C#中YAF.Classes.Data.MsSqlDbConnectionManager.CloseConnection方法的典型用法代碼示例。如果您正苦於以下問題:C# MsSqlDbConnectionManager.CloseConnection方法的具體用法?C# MsSqlDbConnectionManager.CloseConnection怎麽用?C# MsSqlDbConnectionManager.CloseConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在YAF.Classes.Data.MsSqlDbConnectionManager的用法示例。


在下文中一共展示了MsSqlDbConnectionManager.CloseConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: poll_save


//.........這裏部分代碼省略.........
                                    {

                                        cmd.Parameters.Add("?PollID{0}".FormatWith(choiceCount1), MySqlDbType.Int32).Value =
                                            myPollID;
                                        cmd.Parameters.Add(String.Format("?Choice{0}", choiceCount1), MySqlDbType.VarChar).
                                            Value
                                            = question.Choice[0, choiceCount1];
                                        cmd.Parameters.Add(String.Format("?Votes{0}", choiceCount1), MySqlDbType.Int32).
                                            Value =
                                            0;
                                        cmd.Parameters.Add(String.Format("?ChoiceObjectPath{0}", choiceCount1),
                                                           MySqlDbType.VarChar).Value =
                                            question.Choice[1, choiceCount1].IsNotSet()
                                                ? String.Empty
                                                : question.Choice[1, choiceCount1];
                                        cmd.Parameters.Add(String.Format("?ChoiceMimeType{0}", choiceCount1),
                                                           MySqlDbType.VarChar).Value =
                                            question.Choice[2, choiceCount1].IsNotSet()
                                                ? String.Empty
                                                : question.Choice[2, choiceCount1];
                                    }
                                }
                                MsSqlDbAccess.Current.ExecuteNonQuery(cmd, false);

                            }

                            sb = new StringBuilder();
                            // fill a pollgroup field - double work if a poll exists
                            if (question.TopicId > 0)
                            {

                                sb.Append("UPDATE ");
                                sb.Append(MsSqlDbAccess.GetObjectName("Topic"));
                                sb.Append(" SET PollID = ?NewPollGroupID WHERE TopicID =?TopicID; ");

                            }

                            // fill a pollgroup field in Forum Table if the call comes from a forum's topic list
                            if (question.ForumId > 0)
                            {
                                sb.Append("UPDATE ");
                                sb.Append(MsSqlDbAccess.GetObjectName("Forum"));
                                sb.Append(" SET PollGroupID= ?NewPollGroupID WHERE ForumID= ?ForumID; ");
                            }

                            // fill a pollgroup field in Category Table if the call comes from a category's topic list
                            if (question.CategoryId > 0)
                            {
                                sb.Append("UPDATE ");
                                sb.Append(MsSqlDbAccess.GetObjectName("Category"));
                                sb.Append(" SET PollGroupID = ?NewPollGroupID WHERE CategoryID= ?CategoryID; ");
                            }

                            using (MySqlCommand cmdPoll = MsSqlDbAccess.GetCommand(sb.ToString(), true))
                            {
                               cmdPoll.Transaction = trans;
                                cmdPoll.Parameters.Add("?NewPollGroupID", MySqlDbType.Int32).Value = pollGroupId;
                                if (question.TopicId > 0)
                                {
                                    cmdPoll.Parameters.Add("?TopicID", MySqlDbType.Int32).Value = question.TopicId;
                                }

                                // fill a pollgroup field in Forum Table if the call comes from a forum's topic list
                                if (question.ForumId > 0)
                                {
                                    cmdPoll.Parameters.Add("?ForumID", MySqlDbType.Int32).Value = question.ForumId;
                                }

                                // fill a pollgroup field in Category Table if the call comes from a category's topic list
                                if (question.CategoryId > 0)
                                {
                                    cmdPoll.Parameters.Add("?CategoryID", MySqlDbType.Int32).Value = question.CategoryId;
                                }

                                MsSqlDbAccess.Current.ExecuteNonQuery(cmdPoll, false);

                            }

                            /*if (ret.Value != DBNull.Value)
                       {
                           return (int?)ret.Value;
                       }*/
                           trans.Commit();
                            return pollGroupId;
                       }
                        catch (Exception e)
                        {
                           trans.Rollback();
                           throw new Exception(e.Message);

                        }
                        finally
                      {
                          connMan.CloseConnection();
                      }
                    }
                }
            }
            return null;
        }
開發者ID:vzrus,項目名稱:YetAnotherForumExtraDataLayers,代碼行數:101,代碼來源:LegacyDb.cs


注:本文中的YAF.Classes.Data.MsSqlDbConnectionManager.CloseConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。