I think my problem is in line 22. Visual Studio said
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Additional information: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
in line 26.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using System.Data;
using System.Windows.Forms;
using System.Web;
namespace moshaveramlak
{
public class House
{
// The method for inserting into database.
public void SaveHouse()
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\alireza\\Documents\\House.accdb");
try
{
conn.Open();
// Insert code to process data.
}
/*catch (Exception ex)
{
MessageBox.Show("Failed to connect to data source");
}*/
finally
{
conn.Close();
}
}
}
}