为什么程序不包含静态Main

时间:2019-03-14 15:13:48

标签: c#

我是C#的新手,所以不要太过粗俗。我有Form1调用Form2。当我去运行程序时,出现以下错误消息:

“ CS5001程序不包含适用于入口点的静态“ Main”方法”

我不知道它是Form1还是Form2,它是什么意思?感谢您的帮助。

Form1

namespace RM_Main
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnBoxRIDMaintenance_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmBoxRID frm = new frmBoxRID();
            frm.ShowDialog();

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

Form2

namespace RM_Main
{
    public partial class frmBoxRID : Form
    {
        public frmBoxRID()
        {
            InitializeComponent();
        }

        private void frmBoxRID_Load(object sender, EventArgs e)
        {
            var conn = "Server=NSI-TECHPRD01-W\\TECHPRD01;" +
                      "Database=Record_Retention;" +
                      "Trusted_Connection=True";
            var select = "SELECT * FROM T000000_BOXRID;";
            var c = new SqlConnection(conn); // Your Connection String here
            var dataAdapter = new SqlDataAdapter(select, c);

            var commandBuilder = new SqlCommandBuilder(dataAdapter);
            var ds = new DataSet();
            dataAdapter.Fill(ds);
            dgvBoxRID.ReadOnly = true;
            dgvBoxRID.DataSource = ds.Tables[0];
        }
    }
}

0 个答案:

没有答案