そのため、エラーを修正した後、エラーラベル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();
}
}
どんな入力でも大歓迎です
編集:
OK、だから私は取り除きました
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