从不同于 CodeBehind 的 class 更新 SQL 数据库 - ' 由于其保护级别而无法访问

Updating SQL database from separate class than CodeBehind - ' is inaccessible due to its protection level

ASPX

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" 
         AutoEventWireup="true" CodeBehind="TestSID.aspx.cs" 
         Inherits="AdminConsole.Pages.TestSID" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
        <asp:TextBox ID="RegisteringAiD" runat="server" CssClass="form-control" 
             Wrap="False" OnTextChanged="RegisteringAiD_TextChanged"></asp:TextBox>

代码隐藏

public partial class TestSID : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public TextBox MakePublicTxt
    {
        get { return this.RegisteringAiD; }
    }

    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        SubmitBtn.Enabled = true;
        App_Code.SQLDBSubmits.SIDSubmit();
        SubmitBtn.Enabled = false;
    }       
}

Class 向数据库添加数据

static class SQLDBSubmits
{
    internal static void SIDSubmit()
    {
        SqlConnection con = SQLDBAccess.DefaultConnection();
        SqlCommand cmd = new SqlCommand("INSERT INTO TestSID(@RegisteringAiD)", con);
        cmd.Parameters.Clear();

        cmd.Parameters.AddWithValue("RegisteringAiD", Pages.TestSID.RegisteringAiD.Text);
    }
}

因为我使用单独的 class 文件而不是代码隐藏来执行 SQL 更新,所以我收到此错误:

Compiler Error Message: CS0122: 'TestSID.RegisteringAiD' is inaccessible due to its protection level.

我已经研究了好几天了,但似乎无法弄明白。

试试这个:

static class SQLDBSubmits
{
    internal static void SIDSubmit(string aid)
    {
        SqlConnection con = SQLDBAccess.DefaultConnection();
        SqlCommand cmd = new SqlCommand("INSERT INTO TestSID(@RegisteringAiD)", con);
        cmd.Parameters.Clear();

        cmd.Parameters.AddWithValue("RegisteringAiD", aid);
    }
}

和代码隐藏

 App_Code.SQLDBSubmits.SIDSubmit(MakePublicTxt.Text);