コード例 #1
0
ファイル: ArticleComment.cs プロジェクト: sumdood31/DIYFE
        public bool InsertComment(ArticleComment comment)
        {
            string queryString = "INSERT INTO [MLB].[dbo].[ArticleComment] " +
                                  " ([ArticleId],[PosterName],[PosterEmail],[PosterWebSite],[CommentText],[RepyToCommentId]) " +
                                   " VALUES (@ArticleId,@PosterName,@PosterEmail,@PosterWebSite,@CommentText,@RepyToCommentId)";

            using (SqlConnection connection = new SqlConnection(Base.conn))
            {
                // Create the Command and Parameter objects.
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@ArticleId", comment.ArticleId);
                command.Parameters.AddWithValue("@PosterName", comment.PosterName);
                command.Parameters.AddWithValue("@PosterEmail", comment.PosterEmail);
                command.Parameters.AddWithValue("@PosterWebSite", comment.PosterWebSite);
                command.Parameters.AddWithValue("@CommentText", comment.Text);
                command.Parameters.AddWithValue("@RepyToCommentId", comment.RepyToCommentId);
                try
                {
                        connection.Open();
                        command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    DIYError sError = new DIYError(ex);
                }
            }

            return true;
        }
コード例 #2
0
ファイル: ArticleComment.cs プロジェクト: GokitaU/DIYFE
        public bool InsertComment(ArticleComment comment)
        {
            string queryString = "INSERT INTO [MLB].[dbo].[ArticleComment] " +
                                 " ([ArticleId],[PosterName],[PosterEmail],[PosterWebSite],[CommentText],[RepyToCommentId]) " +
                                 " VALUES (@ArticleId,@PosterName,@PosterEmail,@PosterWebSite,@CommentText,@RepyToCommentId)";

            using (SqlConnection connection = new SqlConnection(Base.conn))
            {
                // Create the Command and Parameter objects.
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@ArticleId", comment.ArticleId);
                command.Parameters.AddWithValue("@PosterName", comment.PosterName);
                command.Parameters.AddWithValue("@PosterEmail", comment.PosterEmail);
                command.Parameters.AddWithValue("@PosterWebSite", comment.PosterWebSite);
                command.Parameters.AddWithValue("@CommentText", comment.Text);
                command.Parameters.AddWithValue("@RepyToCommentId", comment.RepyToCommentId);
                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    DIYError sError = new DIYError(ex);
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: ServiceController.cs プロジェクト: sumdood31/DIYFE
        public ActionResult PostComment(ArticleComment comment)
        {
            var data = new object();

            ArticleComment ac = new ArticleComment();
            if (ac.InsertComment(comment))
            {
                data = new { success = true, obj = comment };
            }
            else
            {
                data = new { success = false, message = "Failed to insert new comment." };
                return Json(data);
            }

            return Json(data);
        }