I made a Accounts Project in c sharp with access2016 database, in this I want to enter user data in user management form when I click on save button this error appears
"System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement" in c#.
Here is my code;
public partial class frmUsers : MetroFramework.Forms.MetroForm
{
OleDbConnection con = new OleDbConnection(ConfigurationManager.AppSettings ["con"]);
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DataBase.accdb;");
public frmUsers()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
//string InsertPur= "insert into [Users] (UserCode,UserName,UserID,Password,Designation,ContactNo,UserType) values (" + txtUserCode.Text + ", '" + txtUserName.Text + "','" + txtUserID.Text + "','" + txtPassword.Text + "','" + txtDesignation.Text + "'," + txtContactNo.Text + ",'" + cboxUserType.Text + "')";
OleDbDataAdapter da = new OleDbDataAdapter("insert into Users(UserCode,UserName,UserID,Password,Designation,ContactNo,UserType) values (" + txtUserCode.Text + ", '" + txtUserName.Text + "', '" + txtUserID.Text + "', '" + txtPassword.Text + "', '" + txtDesignation.Text + "', " + txtContactNo.Text + ", '" + cboxUserType.Text + "')", con);
DataSet ds = new DataSet();
da.Fill(ds); //**Error Pointed here**
ViewData();
clearData();
txtUserName.Focus();
}
}