What is this error message mean? CS0115

BenTam 1,701 Reputation points
2024-11-02T09:17:01.64+00:00

Dear all,

How to fix the error: CS0115 'Student_Form.Dispose(bool)': no suitable method found to override NewTims C:\Users\benta\source\repos\NewTims\Student_Form.Designer.cs 14

using System.Data;
using System.Data.SqlClient;

namespace NewTims
{
    public partial class Student_Form
    {
        private static int nStudentID = 0; //Declare it as a private field and use the static modifier
        private static string cEngName = "0";

        public Student_Form()
        {
            InitializeComponent();
            RetrieveData();
        }

        public void RetrieveData()
        {
            bool bDesc = false;
            string cConnectionString = "Data Source=(local); Initial Catalog=Tims; Integrated Security=True";

            using (SqlConnection connection = new SqlConnection(cConnectionString))
            {
                connection.Open(); // Ensure the connection is opened before using it

                string PreSelectQry = "Select top 1 StudentID, EngName from student where EngName >= '"
                    + cEngName + "' and studentid > " + nStudentID.ToString()
                    + " order by " + (nStudentID == 0 ? "StudentID" : "EngName, StudentID");
                SqlCommand command = new SqlCommand(PreSelectQry, connection);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataSet ds = new DataSet();
                adapter.Fill(ds, "PreStudent");
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    nStudentID = dt.Rows[0].Field<int>("StudentID");
                    string cEngName = dt.Rows[0].Field<string>("EngName").ToString();
                }
                string SelectQuery = @"select Top 1 s.*, o.CourseID, o.SubjectID, g.EngName as GroupName, c.SubjectID"
                    + " from student s"
                    + " left Join student g on s.memberOf = g.studentid"
                    + " left join studentCourse c on s.studentid = c.studentid"
                    + " left join course o on c.CourseID = o.CourseID"
                    + " where s.EngName >= '" + cEngName
                    + "' order by s.EngName" + (bDesc ? " desc" : "").ToString()
                    + ", s.StudentID" + (bDesc ? " desc" : "").ToString();

                //and s.StudentID > "+nStudentID.ToString()

                command = new SqlCommand(SelectQuery, connection);
                adapter = new SqlDataAdapter(command);
                ds = new DataSet();
                adapter.Fill(ds, "Student");

                dt = ds.Tables["Student"];
                if (dt.Rows.Count > 0)
                {
                    DataRow r = dt.Rows[0];
                    cEngName = r.Field<string>("EngName").Trim();
                    string Sex = r.Field<string>("Sex");
                    if (Sex.Trim() != "O")
                    {
                        int iFirstBlank = cEngName.IndexOf(" ", 0);
                        Surname_textBox.Text = cEngName.Substring(0, iFirstBlank);
                        Surname_textBox.Visible = true;
                        GivenName_textBox.Text = cEngName.Substring(iFirstBlank + 1);
                        GivenName_textBox.Visible = true;
                        GivenName_label.Visible = true;
                        CompanyName_textBox.Visible = false;
                    }
                    else
                    {
                        Surname_textBox.Text = cEngName;
                        GivenName_label.Visible = false;
                    }
                    Chinese_textBox.Text = r.Field<string>("Chiname");
                    StuID_textBox.Text = string.Format("{0}", r.Field<int>("StudentID").ToString("000000"));
                    HKIDCard_textBox.Text = r.Field<string>("IdCard");
                    TelEmail_textBox.Text = r.Field<string>("TelEmail");
                    MemberOf_xtextBoxButton.MyText = r.Field<string>("GroupName");
                    cEngName = Surname_textBox.Text.Trim() + ", " + GivenName_textBox.Text.Trim();
                    //listView o=Courses_listView;

                }
                else
                {
                    // Handle case when no data is returned
                }
            }
        }
    }
}
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,996 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.