Error 4 The name 'OleDbCommand' does not exist in the current context
Error 6 The name 'OleDbDataAdapter' does not exist in the current context
Error 3 The type or namespace name 'OleDbCommand' could not be found (are you missing a using directive or an assembly reference?)
Error 1 The type or namespace name 'OleDbConnection' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'OleDbConnection' could not be found (are you missing a using directive or an assembly reference?)
Error 5 The type or namespace name 'OleDbDataAdapter' could not be found (are you missing a using directive or an assembly reference?)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string constr = "Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data Source=|DataDirectory|\class.accdb";
OleDbConnection conn = new OleDbConnection(constr);
conn.Open();
string sql = "SELECT * FROM Room";
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
classDataSet data = new classDataSet();
adapter.Fill(data, "room");
dataGridView1.DataSource = data.Tables["room"];
conn.Close();
}
อันนี้โค๊ดคับ
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}