在我的代码中的当前上下文 c# 中不存在

does not exist in the current context c# in my codes

namespace ForumSon.App_Code.DataAccess
{
    public class PostForum
    {
        public static int insertForum(int titleId, string question, string posterName, DateTime datetim)
        {
            int rowsAffected = 0;
            using (SqlConnection connection = ConnectionManager.GetDatabaseConnection())
            {
                SqlCommand command = new SqlCommand("insertForum", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.Add("@titleId", SqlDbType.Int).Value = titleId;
                command.Parameters.Add("@question", SqlDbType.VarChar).Value = question;
                command.Parameters.Add("@posterName", SqlDbType.VarChar).Value = posterName;
                command.Parameters.Add("@datetim", SqlDbType.DateTime).Value = datetim;


                rowsAffected = command.ExecuteNonQuery();
            }

            return rowsAffected;
        }
    }
}

以上是我的PostForumclass;我尝试在我的按钮点击中使用它,但错误报告 "it does not exist in the current context"

我该如何处理?我需要在我们的网站上做一个 Forum 项目。

我在以下行遇到此错误:

PostForum.insertForum(ctitleId, question, posterName, datetime);

我假设您的 按钮点击 是在另一个程序集中,请说 ForumSon.WebSite.

当您不想在该 web-UI-assembly 中使用您的 PostForum-class 时,您首先必须添加对您的 DataAccess-assembly 的引用并添加消费中的 using 指令 ​​UI-class:

using ForumSon.App_Code.DataAccess;

https://msdn.microsoft.com/en-us/library/wkze6zky.aspx