OleDBException error INSERT
Construyo una aplicación c # donde puedes iniciar sesión y puedo registrar una nueva cuenta. Pero cuando hago clic en la cuenta nueva de mi botón y relleno los campos requeridos, aparece el siguiente error:
vcom.ExecuteNonQuery (); -> OleDBException no fue manejado. La instrucción INSERT contiene un syntaxerror.
Vea aquí abajo nuestro código:
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 System.Data.OleDb;
namespace Eindopdracht
{
public partial class maak_account : Form
{
OleDbConnection vcon = new OleDbConnection(@"provider= microsoft.jet.oledb.4.0;data source=sample.mdb");
public maak_account()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection vcon = new OleDbConnection(@"provider= microsoft.jet.oledb.4.0;data source=sample.mdb");
vcon.Open();
string test = string.Format("insert into inlog (PASSWORD, Username, leeftijd, gewicht) VALUES ('" + textBox2.Text + "','" + textBox1.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')");
OleDbCommand vcom = new OleDbCommand(test, vcon);
vcom.ExecuteNonQuery();
MessageBox.Show("Uw gegevens zijn opgeslagen");
vcom.Dispose();
}
}
}