我不明白爲什麼我在這裏說錯誤:Could not find installable ISAM
。我正在嘗試將數據添加到似乎有問題的Access文件中。在我的代碼中可能是'找不到可安裝的ISAM'錯誤的原因?
我不知道爲什麼這樣做不起作用,因爲我在刪除每個條目時使用的是嚴格的代碼。
這裏有什麼明顯的錯誤嗎?
// Creating a query for each type of data.
string sqlPC = @"INSERT INTO PersonalData([Type], [UserName], [Password])
VALUES(@Type, @UserName, @Password)";
string sqlWS = @"INSERT INTO PersonalData([Type], [URL], [UserName], [Password])
VALUES(@Type, @URL, @UserName, @Password)";
string sqlSC = @"INSERT INTO PersonalData([Type], [SoftwareName], [SerialCode])
VALUES(@Type, @SoftwareName, @SerialCode)";
HashPhrase hashPhrase = new HashPhrase();
Security security = new Security();
private void InsertData(string sql)
{
string hashShortPass = hashPhrase.ShortHash(pass);
string connectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0};
Persist Security Info=False; Jet OLEDB: Database Password={1};";
using (OleDbConnection connection = new OleDbConnection())
{
connection.ConnectionString =
string.Format(connectionString, filePath, hashShortPass);
using (OleDbCommand command = new OleDbCommand(sql, connection))
{
OleDbParameter prmType = new OleDbParameter
("@Type", security.EncryptAES(cmbType.Text, pass, user));
command.Parameters.Add(prmType);
if (cmbType.SelectedIndex == 0)
{
OleDbParameter prmUserName = new OleDbParameter
("@UserName", security.EncryptAES
(txtUserName.Text.Trim(), pass, user));
OleDbParameter prmPassword = new OleDbParameter
("@Password", security.EncryptAES
(txtPassword.Text, pass, user));
command.Parameters.Add(prmUserName);
command.Parameters.Add(prmPassword);
}
else if (cmbType.SelectedIndex == 1)
{
OleDbParameter prmURL = new OleDbParameter
("@URL", security.EncryptAES
(txtURL.Text.Trim(), pass, user));
OleDbParameter prmUserName = new OleDbParameter
("@UserName", security.EncryptAES
(txtUserName.Text.Trim(), pass, user));
OleDbParameter prmPassword = new OleDbParameter
("@Password", security.EncryptAES
(txtPassword.Text, pass, user));
command.Parameters.Add(prmURL);
command.Parameters.Add(prmUserName);
command.Parameters.Add(prmPassword);
}
else if (cmbType.SelectedIndex == 2)
{
OleDbParameter prmSoftwareName = new OleDbParameter
("@SoftwareName", security.EncryptAES
(txtSoftwareName.Text.Trim(), pass, user));
OleDbParameter prmSerialCode = new OleDbParameter
("@SerialCode", security.EncryptAES
(txtSerialCode.Text.Trim(), pass, user));
command.Parameters.Add(prmSoftwareName);
command.Parameters.Add(prmSerialCode);
}
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
}
}
的ACE供應商未正確安裝上你的機器。任意嘗試重新安裝它,請在superuser.com上尋求更多幫助。 http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23734 –
@Hans Passant:如果是這樣,爲什麼我可以刪除一個條目,但不能添加一個? – NewHelpNeeder