SQL syntax error in MySql [duplicated]

1

This is the error that presents me when I want to save my data now, sorry that I did not raise it.

    
asked by Nataliel 17.08.2017 в 18:05
source

2 answers

4

The error is clear, it tells you that you have an error in your syntax of your SQL statement. you are passing the value System.Windows.Forms.TextBox , because, I suppose that in your string you assigned the value of the textbox nadamás, type:

String Sql="Insert into X Values"+TuTextBox;

when (as I remember) it should be:

String Sql="Insert into X Values"+TuTextBox.Text;

X is a reference to the table, and TuTextBox is the textbox that is generating the error.

    
answered by 17.08.2017 в 18:18
0

The error that it gives you is by type of data that you want to store in the table, most likely it is of type integer and you in the sql syntax of the text

To correct it you have 2 options to change the data type in the table to text or simply load the text of your text box, an example would be like this:

con.Ejecutar_Accion("INSERT INTO 'categoria'('Nivel_Sub', 'Denominacion', 'Area', 'Observacion') VALUES ('"+txtNivel.Text
            +"','"+txtDenominacion.Text+"','"+CBArea.Text+"','"+RTBObservaciones.Text+"')", "rh", "Error al dar de alta la categoria");

You just have to put the name of your text box plus the period and the text property:

txtDenominacion.Text
    
answered by 17.08.2017 в 20:27