저는 데이터베이스를 배우기 위해 Access 2007과 C#을 사용하고 있습니다. 지금까지 그것은 거칠었지만 나는 비교적 잘 처리 할 수있었습니다. 내가해야 할 일은 내 데이터베이스 테이블을 쿼리하는 것입니다. 사용자가 핀을 기준으로 계산 한 금액을 계산합니다. 클릭 할 때 데이터베이스를 쿼리하는 Windows Form에 단추를 배치했습니다. 정상/당 버튼을 클릭하거나 실행하면 다음 오류가 나타납니다. C# 데이터베이스 사용 중 또는 사용 권한 오류
내 예외 오류 : 내 코드Essentially my question is this: How would I go about setting the permissions up so that my program can freely access the Access Database I have?
Exception: System.Data.OleDb.OleDbException: The Microsoft Office Access database engine cannot open or write to the file 'C:\Users\Public'. It is already opened exclusively by another user, or you need permission to view and write its data.
:
public partial class frmPin : Form
{
static string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Public;Persist Security Info=True";
static private int pin = 11; //The First Pin in my records, for debugging I inserted it directly.
static string selectStatement = "SELECT Amount FROM Accounts WHERE(PIN=" + pin + ")";
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(selectStatement);
public frmPin()
{
InitializeComponent();
}
private void btnQry_Click(object sender, EventArgs e)
{
try
{
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader(); // executes query
while (reader.Read()) // if can read row from database
{
txtBx.Text = reader.GetValue(1).ToString();
}
}
catch (Exception ex)
{
txtBx.Text = "Exception: " + ex; // Displays Exception
}
finally
{
conn.Close(); // finally closes connection
}
}
아, 파일 자체를 포함시켜야합니다. 도움을 주셔서 대단히 감사합니다. – Xesaniel
* .accdb 파일 인 경우 사용자 수준 보안이 엔진에서 제거되었으므로 그룹/사용자에 대한 권한을 거부 할 수 없습니다. – onedaywhen
Jet ULS에는 DENY 권한이 없었기 때문에 aaronis가 NTFS 보안을 언급하고 있음이 분명합니다. –