因此,在修复了我得到的错误之后,当我通过错误标签studentHelperClass.Form1.cmbBox is inaccessible due to its protection level
启动我的程序时,我得到了这个错误。Error reading the database, method or operation is not implemented
这是我的代码:
public partial class Form1 : Form
{
MySqlConnection conn; // connection object;
string connstring = "server=localhost;user Id=root;database=collegesystem;Convert Zero Datetime=True ";
public Form1()
{
InitializeComponent();
connection();
selectStudent();
}
private void selectStudent()
{
try
{
studentHelperClass.studentHC.insertMethod();
}
catch (Exception err)
{
lblInfo.Text = " Error reading the database.";
lblInfo.Text += err.Message;
}
}
那就是表单的代码,下面是带有方法的类
class studentHC : Form1
{
public studentHC()
{
InsertMethod();
}
private void InsertMethod()
{
MySqlConnection conn; // connection object;
string connstring = "server=localhost;user Id=root;database=collegesystem;Convert Zero Datetime=True ";
conn = new MySqlConnection(connstring);
conn.Open();
using (var command = new MySqlCommand("SELECT * FROM person", conn))
{
using (var myReader = command.ExecuteReader())
{
cmbBox.Items.Add(myReader["personID"]);
}
}
}
internal static void insertMethod()
{
throw new NotImplementedException();
}
}
任何投入将不胜感激
编辑:
好的,所以我摆脱了
internal static void insertMethod()
{
throw new NotImplementedException();
}
我改变了
public studentHC()
{
InsertMethod();
}
private void InsertMethod()
到
public studentHC()
{
insertMethod();
}
private void insertMethod()
现在它说studentHelperClass.studentHC.insertMethod()' is inaccessible due to its protection level