3

従来の ASP を使用して、フォームに収集されたデータを Access 2007 データベースに書き込む古い Web アプリケーションを継承しました。

現在、キリル文字で入力を収集できるようにする必要があります。

私はコードページ/文字セットに完全に慣れておらず、非ラテンアルファベットを扱っています。

エントリ フォーム ページの文字セットを ISO-8859-1 に変更してみましたが、文字の ascii 値が格納されているようです (例: #1076;)。したがって、それはブラウザによって解釈および読み取られますが、そのデータを Excel にエクスポートして必要な部門に渡すという点ではほとんど役に立ちません。

だから私の質問は:

Web フォームからキリル文字をキャプチャして、アクセス テーブルにキリル文字として挿入する簡単な方法はありますか?

または交互に

Access データベース内に、10 進数値 (#1076;) を Access 自体内のキリル文字に変換できるツールまたは設定はありますか。

4

1 に答える 1

4

ページに UTF-8 を使用している場合は、動作するはずです (ただし、以下の重要な注意事項を参照してください)。Access が Unicode 文字を UTF-8 として内部的に保存しないのは事実ですが、Access OLEDB ドライバーが変換を処理します。

次のサンプル スクリプトを検討してください (65001は UTF-8 の「コード ページ」です)。

<%@ CODEPAGE = 65001 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Classic ASP Unicode Test</title>
</head>
<body bgcolor="white" text="black">
<%
Dim con, cmd, rst
Const adVarWChar = 202
Const adParamInput = 1
Set con = CreateObject("ADODB.Connection")
con.Mode = 3  ' adModeReadWrite
con.Open _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\_wwwdata\unicodeTest.mdb;"
If Len(Trim(Request.Form("word"))) > 0 Then
    Set cmd = CreateObject("ADODB.Command")
    cmd.ActiveConnection = con
    cmd.CommandText = "INSERT INTO vocabulary (word, language, english_equiv) VALUES (?,?,?)"
    cmd.Parameters.Append cmd.CreateParameter("?", adVarWChar, adParamInput, 255, Request.Form("word"))
    cmd.Parameters.Append cmd.CreateParameter("?", adVarWChar, adParamInput, 255, Request.Form("language"))
    cmd.Parameters.Append cmd.CreateParameter("?", adVarWChar, adParamInput, 255, Request.Form("english_equiv"))
    cmd.Execute
    Set cmd = Nothing
End If
%>
<h2>Word list:</h2>
<table border=1>
    <tr>
        <th>word</th><th>language</th><th>english_equiv</th>
    </tr>
<%
Set rst = CreateObject("ADODB.Recordset")
rst.Open _
        "SELECT * FROM vocabulary ORDER BY ID", _
        con, 3, 3
Do Until rst.EOF
    Response.Write "<tr>"
    Response.Write "<td>" & rst("word").Value & "</td>"
    Response.Write "<td>" & rst("language").Value & "</td>"
    Response.Write "<td>" & rst("english_equiv").Value & "</td>"
    Response.Write "</tr>"
    rst.MoveNext
Loop
Response.Write "</table>"
rst.Close
Set rst = Nothing
con.Close
Set con = Nothing
%>
<h2>Add a new entry:</h2>
<form action="<% Response.Write Request.ServerVariables("SCRIPT_NAME") %>" method="POST">
<table>
    <tr>
        <td align="right">word:</td>
        <td><input type="text" name="word"></td>
    </tr>
    <tr>
        <td align="right">language:</td>
        <td><input type="text" name="language"></td>
    </tr>
    <tr>
        <td align="right">english_equiv:</td>
        <td><input type="text" name="english_equiv"></td>
    </tr>
    <tr>
        <td></td>
        <td align="center"><input type="submit" value="Submit"></td>
    </tr>
</table>
</body>
</html>

Access データベースの [vocabulary] という名前のテーブルから開始

AccessTableBefore.png

表示される ASP ページを読み込むと、

        AspPage1.png

ロシア語の新しいエントリを追加すると

        AspPage2.png

[送信] をクリックすると、ページが更新されます。

        AspPage3.png

Access でテーブルを確認すると、

AccessTableAfter.png

重要な注意点

Access データベースを Web アプリケーションのバックエンド データ ストアとして使用しないでください。Microsoftは、そうしないことを強くお勧めします(参照:ここ)。

于 2014-02-27T15:05:48.637 に答える