当前位置: 首页>>代码示例>>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;未经允许,请勿转载。