You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
Posted by: kaiz moto
Date: June 01, 2021 10:54PM

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Ошибка выскакивает в adapter.Fill(table); (35 строка).
После попытки выбора второй строки ... или при попытке изменения выбранного пункта в первой строке ... В datagridview1 - см строки 54-68
Думал проблема связана с MySQL - переустановил - не помогло.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdvancedWizardControl.Wizard;
using AdvancedWizardControl.WizardPages;
using AdvancedWizardControl.Enums;
using AdvancedWizardControl.EventArguments;
using AdvancedWizardControl;
using Dapper;
using MySql.Data.MySqlClient;
using System.Diagnostics;
using System.IO;

namespace IT_A_stroy
public partial class WizardPageEventArgs : Form
public int PreviousPage { get; set; }
//DataSet ds;
MySqlDataAdapter adapter;
readonly string connectionString = "server=localhost;user=root;database=a_stroy;password=q1w2e3r4t5y6u7i8o9p0;";
//string sql_1 = "select Progess, Progress_info from a_stroy.step3 where 1=2";
public DataTable Execute(string script)
using (MySqlConnection connection = new MySqlConnection(connectionString))
DataTable table = new DataTable();
adapter = new MySqlDataAdapter(script, connection);
return table;

private void СomboBox1_SelectedValueChanged(object sender, EventArgs e)
if (comboBox1.SelectedValue != null)
column1.DataSource = Execute($"SELECT id_Object, id_customer, Name_object FROM a_stroy.object where id_customer = {comboBox1.SelectedValue};");
column1.DisplayMember = "Name_object";
column1.ValueMember = "id_Object";
int countRow = dataGridView1.RowCount == 1 ? 1 : dataGridView1.RowCount - 1;
//int DGV1 = comboBox1.SelectedIndex;

private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
ComboBox cbDgv = e.Control as ComboBox;
cbDgv.SelectedValueChanged -= CbDgv_SelectedValueChanged;
cbDgv.SelectedValueChanged += CbDgv_SelectedValueChanged;

private void CbDgv_SelectedValueChanged(object sender, EventArgs e)
ComboBox box = sender as ComboBox;
column2.DataSource = Execute($"SELECT id_Object, Name_works FROM a_stroy.words_object where id_Object = {box.SelectedValue}");
column2.DisplayMember = "Name_works";
column2.ValueMember = "id_Object";

private void DataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)

Options: ReplyQuote

Written By
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
June 01, 2021 10:54PM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.