اذهب إلى المحتوى
  • 0

MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQ

السؤال

نشر

هناك خطا ما موجود لم اتمكن من معرفته 

public void LoadRecord()
        {
            dataGridView1.Rows.Clear();
            conn.Open();
            
            
           
            cmd = new MySqlCommand("SELECT `Employee ID`,`EmpName`,`RegNO`,`Job_Title`,`Position`,`Hiring_Date`,`DeptId`,`Birthdate`,`Gender`,`Country' ,`Phone`,`Address`,`Photo` FROM `employee`", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                dataGridView1.Rows.Add(dataGridView1.Rows.Count + 1, dr["Employee ID"].ToString(), dr["EmpName"].ToString(), dr["RegNO"].ToString(), dr["Job_Title"].ToString(), dr["Position"].ToString(), dr["Hiring_Date"], dr["DeptId"].ToString(), dr["Birthdate"], dr.ToString(), dr["Gender"].ToString(), dr["Country"].ToString(), dr["Phone"].ToString(), dr["Address"].ToString(), dr["Photo"].ToString());
            }
            dr.Close();
            conn.Close();

        }

 

FormEmployee.cs

Recommended Posts

  • 0
نشر
بتاريخ On 13‏/1‏/2023 at 11:15 قال علي محسن:

تحتاج وضع رسالة الخطأ التي تظهر لك كاملة حتى نتمكن من مساعدتك

MySql.Data.MySqlClient.MySqlException
  HResult=0x80004005
  Message=You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`,`Address`,`Photo` FROM `employee`' at line 1
  Source=MySql.Data
  StackTrace:
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at Transparent_Form.FormEmployee.LoadRecord() in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 90
   at Transparent_Form.FormEmployee.FormEmployee_Load(Object sender, EventArgs e) in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 34
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

  This exception was originally thrown at this call stack:
    [External Code]
    Transparent_Form.FormEmployee.LoadRecord() in FormEmployee.cs
    Transparent_Form.FormEmployee.FormEmployee_Load(object, System.EventArgs) in FormEmployee.cs
    [External Code]

بتاريخ 3 دقائق مضت قال Abdu Mohamed:

MySql.Data.MySqlClient.MySqlException
  HResult=0x80004005
  Message=You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`,`Address`,`Photo` FROM `employee`' at line 1
  Source=MySql.Data
  StackTrace:
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at Transparent_Form.FormEmployee.LoadRecord() in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 90
   at Transparent_Form.FormEmployee.FormEmployee_Load(Object sender, EventArgs e) in C:\Users\Abdu Mohamed\source\repos\Student Management System\Transparent Form\FormEmployee.cs:line 34
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

  This exception was originally thrown at this call stack:
    [External Code]
    Transparent_Form.FormEmployee.LoadRecord() in FormEmployee.cs
    Transparent_Form.FormEmployee.FormEmployee_Load(object, System.EventArgs) in FormEmployee.cs
    [External Code]

Line 90

cmd = new MySqlCommand("SELECT `Employee ID`,`EmpName`,`RegNO`,`Job_Title`,`Position`,`Hiring_Date`,`DeptId`,`Birthdate`,`Gender`,`Country' ,`Phone`,`Address`,`Photo` FROM `employee`", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())

Line 34 

private void FormEmployee_Load(object sender, EventArgs e)
        {
            LoadRecord();
            dataGridView1.RowTemplate.Height = 25;
        }

 

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...