我正在尝试连接到 Microsoft Access 数据库,但我无法使用 c# 进行连接,但无法使用 sql 连接创建登录表单,这也是本地连接
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source ='(local)';Initial Catalog ='UserAccounts.accdb';Integrated Security=true");
SqlDataReader rdr = null;
try
{
conn.Open();
MessageBox.Show("Working");
}
catch (Exception)
{
MessageBox.Show("Error with the databse connection");
}
finally
{
Console.ReadLine();
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
}
}