Welcome aboard! We are happy you are here and wish you good net-raft!
using System;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connetionString = null;
OleDbConnection cnn ;
OleDbCommand cmd ;
string sql = null;
OleDbDataReader reader ;
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;";
sql = "Select * from customers";
cnn = new OleDbConnection(connetionString);
try
{
cnn.Open();
cmd = new OleDbCommand(sql, cnn);
reader = cmd.ExecuteReader();
while (reader.Read())
{
MessageBox.Show(reader.GetValue(0) + " - " + reader.GetValue(1) + " - " + reader.GetValue(2) + " - " + reader.GetValue(3));
}
reader.Close();
cmd.Dispose();
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("The connection is refused!");
}
}
}
}
The most helpful C# solutions
detect ie C#C# Click to see more ... 4.7K 853