0

事先可能很重要的信息:

Access 2003 Database (*.mdb)
Table is Linked to SQL Server 2005 Database --> Table
When linked to another Access Database --> Table it works

Program which i use to update : .net 2.0 based C#
Databaselanguage: German?
OleDbConnection used:
 Connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" +
                                                 "Data Source=" + PathToDatabase + ";" +
                                                 "Jet OLEDB:System Database=" + PathToSystemFile+ ";" +
                                                 "User ID=" + SignedUserID + ";" +
                                                 "Password=" + SignedLoginKey + ";");

问题:

我想更新一个字符串,我已成功将其解析为 SQL-Update 语句,例如:

UPDATE [Artikel] SET [Artikelbeschreibung]='УБИТЬ ДРОЗДА 4 СЕРИИ' WHERE products_id=32501;

当我更新字符串时,我的表 [Artikel] 包含满足要求的行(products_id=32501),没有抛出错误或异常。当我检查数据库中的内容时,我只看到:

????? ?????? 4 ?????

来自文件的编码是 UTF8,我已经尝试过但没有运气:Convert ANSI (Windows 1252) to UTF8 in C#

这是我的程序执行的步骤:

 1. Load a file containing the sql statement with placeholder / information in which file, which section, which key the right information will be
  EXAMPLE: UPDATE [Artikel] SET [Artikelbeschreibung]='<<C:\myfile.ini::MySection::MyKey>>' WHERE products_id=32501;

 2. Grab Placeholder / Information
  NOW I HAVE: <<C:\myfile.ini::MySection::MyKey>>

 3. Parse, open File, Search for Section, Search for Key, responding Value of Key as String
  RESPONSE = УБИТЬ ДРОЗДА 4 СЕРИИ

 4. Replace <<C:\myfile.ini::MySection::MyKey>> with УБИТЬ ДРОЗДА 4 СЕРИИ in Original SQL Statement
  RESULT: UPDATE [Artikel] SET [Artikelbeschreibung]='УБИТЬ ДРОЗДА 4 СЕРИИ' WHERE products_id=32501;

 5. Take the string with the Result, open OleDbConnection with Connection as described above and
    do this:
    Connection.Open();
                if (Connection != null)
                {
                    Command = null;
                    Command = Connection.CreateCommand();
                    Command.CommandText = SQL;
                    Command.ExecuteNonQuery();
                    Connection.Close();
                    Connection = null;
                }

 6. Looking into my Database there is only '????? ?????? 4 ?????' instead of 'УБИТЬ ДРОЗДА 4 СЕРИИ'

 Additional Informations: This Only occurs when my Table is linked to a SQL Server, when Table is linked to another Database or is Database directly it works fine.

也许有人可以帮助我,我不知道错误可能在哪里。

如果需要更多信息,请写信,我会尽快通过“编辑”尝试此类文件

4

1 回答 1

0

你有两个选择:

  1. 转到Regional Options并将非 Unicode 程序的语言环境设置为使用西里尔字符的语言环境。

  2. 将西里尔字符串转换为 unicode

    UnicodeFromVal应设置西里尔字母中第一个 Unicode 字符的值。

    Public Function AsUnicode(ByVal Source As String, UnicodeFromVal As Long) As String 
    Dim c As Long
    Dim ByteString() As Byte
    Dim AnsiValue As Integer
    Dim Length As Long
    Length = Len(Source)
    ByteString = StrConv(Source, vbFromUnicode, GetSystemDefaultLCID())
    For c = LBound(ByteString) To UBound(ByteString)
        AnsiValue = ByteString(c)
        If AnsiValue >= 224 And AnsiValue <= 250 Then
            AsUnicode= AsUnicode & ChrW(CLng(AnsiValue - 224 + UnicodeFromVal))
        Else
            AsUnicode= AsUnicode & ChrW(AnsiValue)
        End If
    Next
    End Function
    
于 2013-06-30T07:04:10.763 回答