我不知道为什么我在这里说一个错误: Could not find installable ISAM 我正在尝试将数据添加到似乎有问题的Access文件中。

我不确定为什么这行不通,因为删除每个条目时我使用的是严格要求的代码。

这里有明显的错误吗?

        // 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);
                }
            }
        }
    }

===============>>#1 票数:3

就我而言,我固定为:

我改变:

string conexion = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\Fa.mdb;Database Password=xxx;";

至:

string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\temp\Fa.mdb;Persist Security Info=False; Jet OLEDB:Database Password='xxx';";

===============>>#2 票数:2 已采纳

我变了:

string connectionString = 
            @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0};
              Persist Security Info=False; Jet OLEDB: Database Password={1};";

至:

string connectionString = 
            @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0};
              Persist Security Info=False; Jet OLEDB:Database Password={1};";

而且有效,我有1个不需要的空间...

===============>>#3 票数:0

就我而言,我改变了

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\Export.accdb;Database Password=123"

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\Export.accdb;Jet OLEDB:Database Password=123"

而且有效...

===============>>#4 票数:0

对于插入部分,您有一个名为Password的字段,它是MS Access中的关键字。 您的插入语句应包括[Password]而不是Password。

  ask by NewHelpNeeder translate from so

未解决问题?本站智能推荐: