0
Good morning, I had managed to do everything right up to this error by inserting something into the database. localhost/phpmyadmin - xampp.
It’s something with the id_user
but I don’t know what it is. I don’t use a single insert txtbox
nor combobox
to the id_user
because I don’t know what value I have to give him.
What to do?
Code and prints below!
I’m stuck here for two days and I don’t know how to fix it.
NOTE if it is perciso more INFO I give.
Code Insert>
private void btt_inserir_Click(object sender, EventArgs e)
{
try
{
string Conexao_BD = "datasource=127.0.0.1;port=3306;username=root;password=;database=tempos;SslMode = none;";
string Query = "INSERT INTO `registos`(`id_registo`, `data`, `id_tipo`, `id_tec`, `id_user`, `id_processo`, `id_tarefa`, `horas`, `comentarios`) VALUES (NULL,'" + datatp_1.Text + "','" + comboBox_tipo1.Text + "','" + comboBox_tec1.Text + "','" + txt_teste.Text + "','" + comboBox_pro1.Text + "','" + comboBox_passos1.Text + "','" + txt_horas1.Text + "','" + txt_com1.Text + "')";
MySqlConnection CONEXAO_BD2 = new MySqlConnection(Conexao_BD);
MySqlCommand Comando2 = new MySqlCommand(Query, CONEXAO_BD2);
MySqlDataReader Ler_BD2;
CONEXAO_BD2.Open();
Ler_BD2 = Comando2.ExecuteReader();
msg.Inserir();
CONEXAO_BD2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Briefly the message says that you are trying to insert an item in
registos
that is not informing theid_user
or is informing aid_user
invalid (which does not exist in the tableusers
). I see you’re getting this information fromtxt_teste.Text
, make sure this field is passing a valid value.– Diego Rafael Souza
Yes, that was it but I decided to put the ID value, either 1(for user) or 2(for admin) but now appeared the same error but with the combobox_type1 A of the Types! And I don’t know why or how to solve it. And I would like to know how to eliminate the id_users because I have it but I don’t use it
– gmbc
You got it the previous problem? If you don’t need it, would just delete that column from the table in the bank and go on to not declare it further in your instructions.
– Diego Rafael Souza
The problem is that when I try to delete the id_user column from the table records from this error: https://imgur.com/a/jsZkKO2
– gmbc
Where do I delete it in Relation View?
– gmbc
I can’t say. I’m sorry.
– Diego Rafael Souza