Versuchen eine Verbindung zu accdb-Datenbank mit c# und .NET 4.0

Ich immer eine exception wenn ich versuche zu füllen, den adapter, und ich kann nicht herausfinden, warum. Hier ist mein code. Vielen Dank im Voraus für jede information!

public partial class MainWindow : Window
{
    private OleDbConnection connection;
    private OleDbCommand command;
    private OleDbDataAdapter adapter;
    private DataSet dataset;

    public MainWindow()
    {
        InitializeComponent();

        connection = new OleDbConnection();
        command = new OleDbCommand();
        adapter = new OleDbDataAdapter();
        dataset = new DataSet();

        connection.ConnectionString =
            @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/SoBeWFF.accdb;" +
            "Persist Security Info=False";

        command.Connection = connection;
        command.CommandText = "SELECT * FROM Dishes";

        adapter.SelectCommand = command;

        try
        {
            adapter.Fill(dataset, "Dishes");
        }
        catch (OleDbException)
        {
            MessageBox.Show("Error occured while connecting to database.");
           //Application.Exit();
        }
    }
}
  • Was Ausnahme?
  • Kannst du was posten Ausnahme, die Sie bekommen?
  • Ohne Ausnahme Fehler, ist schwer zu verstehen!!!
Schreibe einen Kommentar