I'm making an Accounting project in C# Visual Studio 2017 and I have three forms:
1st and 2nd form work properly, but when I clicked the button of Product Entry (3rd form), project doesn't go to 3rd form and it shows this error:
System.Data.OleDb.OleDbException: 'Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.'
My code is:
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;
using System.Configuration;
using MetroFramework;
namespace MAARS_Software.Project
{
public partial class frmProductEntry : MetroFramework.Forms.MetroForm
{
OleDbConnection con = new
OleDbConnection(ConfigurationManager.AppSettings["con"]);
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\Backup\OneDrive\Documents\Visual Studio 2017\My
Projects\Backups\MAARS Software\DataBase.accdb;
Jet OLEDB: Database Password = 654321");
public frmProductEntry()
{
InitializeComponent();
}
private void frmProductEntry_Load(object sender, EventArgs e)
{
ViewData();
}
private void Save_btn_Click(object sender, EventArgs e)
{
}
private void Update_btn_Click(object sender, EventArgs e)
{
}
private void Delete_btn_Click(object sender, EventArgs e)
{
}
private void Exit_btn_Click(object sender, EventArgs e)
{
}
void ViewData()
{
OleDbDataAdapter da = new OleDbDataAdapter("Selct * from [Product]",
con);
//DataTable dt = new DataTable();
//da.Fill(dt);
DataSet ds = new DataSet();
da.Fill(ds); //Error stop here
dataGridView1.DataSource = ds.Tables[0];
}
}
}
Typo of select
in OleDbDataAdapter da = new OleDbDataAdapter("Selct * from [Product]", con);
That should be like OleDbDataAdapter da = new OleDbDataAdapter("Select * from [Product]", con);