我想連接我的新項目(ASP.Net核心框架)與Access Database
。MS Access數據庫連接在C#下的ASP.Net核心
我需要做什麼進入:appsettings.json -> "ConnectionStrings"?
而且我必須安裝的東西呢?
這個框架是新的,不幸的是我在互聯網上沒有發現太多東西。
我需要完全連接「Access數據庫」。
我會很高興的詳細信息。具體https://www.connectionstrings.com/
,在這裏:
我想連接我的新項目(ASP.Net核心框架)與Access Database
。MS Access數據庫連接在C#下的ASP.Net核心
我需要做什麼進入:appsettings.json -> "ConnectionStrings"?
而且我必須安裝的東西呢?
這個框架是新的,不幸的是我在互聯網上沒有發現太多東西。
我需要完全連接「Access數據庫」。
我會很高興的詳細信息。具體https://www.connectionstrings.com/
,在這裏:
看起來這裏https://www.connectionstrings.com/access/
而且,試試這個。
using System;
using System.Windows.Forms;
using System.Data.Odbc;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connetionString = null;
OdbcConnection cnn ;
connetionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=yourdatabasename.mdb;";
cnn = new OdbcConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}
試試這個,以及...
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 ;
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;";
cnn = new OleDbConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}
問題是關於ASP.Net核心明確,而不是一個「標準」。 Net應用程序。 Windows窗體和'System.Data.OleDb' /'System.Data.Odbc'命名空間不可用。 –
從這個鏈接: https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/
什麼OLE DB?
OLE DB一直是以統一的方式訪問各種數據源的好方法,但是它基於COM技術,這是一種僅支持Windows的 技術,因此它不適合跨平臺的應用程序,平臺 技術,如.NET核心。它在SQL Server 2014和更高版本中也不受支持。由於這些原因,.NET Core不支持OLE DB 。
舊數據庫被丟棄是錯誤的。 https://blogs.msdn.microsoft.com/sqlnativeclient/2011/08/29/microsoft-is-aligning-with-odbc-for-native-relational-data-access/ – xMRi
這是否幫助https://msdn.microsoft.com/en-us/library/hktw939c(v=vs.85).aspx – June7