2012-05-08 47 views
2

MS AccessシステムをPHP PDOを使用してmySQLシステムに移行します。 PHPがAccessテーブルの一部のレコードを読み込むのを止めるまで、すべてがOKです。このテーブルには、Long Integerデータ型のIDフィールドがあります。理由はわかりませんが、IDは0から16949までで始まり、36573745にジャンプして36581986で終了します.PDOが読み取っていないこれらの高い数値は、理由を理解できません。MSアクセスエラー "更新可能なクエリを使用する必要があります"更新時

これを回避するには、これらの数値を更新して、より低いIDの通常のシーケンスを続行しようとしています。しかし、アクセスは私のクエリを理解することができず、どのように実行するのかわかりません。

これは、このエラーUperation must use an updatable query私を示していますクエリ

UPDATE Validador_Manut SET ID = (
    SELECT (Max(ID) + 1) FROM Validador_Manut WHERE ID < 100000 
) WHERE ID > 100000 

です。

+1

PDOはおそらく、INT値までご大きな数字を丸めています。既にPDOを試しているので、[PDOのbind param](http://www.php.net/manual/en/pdostatement.bindparam.php)を見てください。 (たとえそのクエリが準備された文のようには見えないとしても) – chapman84

+0

@ chapman84私はPDOが私を欺いていると思う。 – DontVoteMeDown

+0

整数の代わりに文字列としてそのparamをバインドし、クエリが機能するかどうかを確認することができます。それが起こっているのかどうかは分かります。 – chapman84

答えて

1

IDを低くしたい場合はs> 100000を16949の後の連続する数字に換算すると、 それでは簡単に試してみませんか?

UPDATE Validador_Manut SET [ID] = [ID]-36556795 WHERE ID > 100000 

36573745から36556795 = 16950

+0

このエラーをスローします。 = S – DontVoteMeDown

+0

これは、IDフィールドがAutonumberであり、変更できないことを意味します。その番号をリセットする簡単な方法はありません。 [MSDNのサポート](http://support.microsoft.com/kb/812718)でこの資料をご覧ください。あなたの質問をよりよく読んで、恐らくあなたは単純にautonumberフラグを削除して(アクセスインターフェイスを使って)、クエリを再試行することができます。 – Steve

+0

はい、予備のデータベースで試しました。IDがAutonumberフィールドの場合、上記のクエリは機能しません。しかし、このdbをmySqlに移行するため、yuoはAutonumberを通常の数値で変更することができ、上記のクエリは動作します – Steve

1

2つのことが私の頭に浮かびます。

1)予約済みキーワード

あなたがテーブル名や列名など特定のキーワードを使用している場合、あなたは本当にあなたの実際の原因を教えていない不可解な例外を取得する可能性があります。

あなたのコラムIDは私には疑わしいと思われます。

短いインターネット検索ではこの理論の証拠は出ませんでしたが、私はIDをどこかでMS Accessの予約語として見たことを思い出すと思います。 Solving the Operation Must Use An Updateable Query error

:あなたはそれを助けることができるようにこの記事が見えます)

  • 角括弧内の列の名前を変更
  • 書き込み列名[](推奨されません)

2に試みることができます

When a Jet 4.0 database (the actual type of database represented by your "Access" mdb file) is deployed in a multi-user environment, an .ldb file is created whenever the database is opened. The .ldb file contains details which include who has opened the file, and primarily serves to prevent opened records being written to by another user.

In the context of an ASP.NET application, who the "user" is will depend on the platform: for XP Pro machines, the user is the ASPNET account. On Windows Server 2003, 2008 and Vista, it is the NETWORK SERVICE account. However, if you have ASP.NET Impersonation enabled, the default user account will be IUSR_machinename, or whichever account you have applied. If you are unsure which account your ASP.NET application is running under, Environment.UserName will return it. To be able to create, write to and delete the required .ldb file, the relevant user needs MODIFY permissions on the folder that the .mdb file is in.

To set this permission, right click on the App_Data folder (or whichever other folder you have put the mdb file in) and select Properties. Look for the Security tab. If you can't see it, you need to go to My Computer, then click Tools and choose Folder Options.... then click the View tab. Scroll to the bottom and uncheck "Use simple file sharing (recommended)". Back to the Security tab, you need to add the relevant account to the Group or User Names box. Click Add.... then click Advanced, then Find Now. The appropriate account should be listed. Double click it to add it to the Group or User Names box, then check the Modify option in the permissions. That's it. You are done.

Note: this fix will also solve "The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data" errors.

+0

いいえ、2番目の提案はうまくいかない、あるいは間違ってしまった、今はいらない。最初の私は思っていません、単純な更新、挿入、または選択に 'ID'フィールドを使用することができます。 – DontVoteMeDown

関連する問題