SCM

[#1011158] {"ERROR: 22021: invalid byte sequence for encoding "UTF8": 0x00"}

View Trackers | Bugs | Download .csv | Monitor

Date:
2012-02-03 19:47
Priority:
3
State:
Open
Submitted by:
Tomas Rybicka (snooker)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.9
Category:
Group:
Resolution:
None
Summary:
{"ERROR: 22021: invalid byte sequence for encoding "UTF8": 0x00"}

Detailed description
Hi,

i have problem with parameter value

Sample code:

Dim cesta As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Dim reg As RegistryKey = Registry.LocalMachine.OpenSubKey(cesta)

Dim parHost As New NpgsqlParameter("@host", NpgsqlTypes.NpgsqlDbType.Text)
Dim parNazevSoftwaru As New NpgsqlParameter("@nazev_softwaru", NpgsqlTypes.NpgsqlDbType.Text)
Dim parHodnotaPolozky As New NpgsqlParameter("@hodnota_polozky", NpgsqlTypes.NpgsqlDbType.Text)
Dim parNazevPolozky As New NpgsqlParameter("@nazev_polozky", NpgsqlTypes.NpgsqlDbType.Text)

Dim strUlozit As String = "uloz_hodnoty(@host, @nazev_softwaru, @nazev_polozky, @hodnota_polozky)"
Dim cmdUlozit As New NpgsqlCommand(strUlozit, Me.conn)
cmdUlozit.CommandType = CommandType.StoredProcedure
cmdUlozit.Parameters.Add(parHost).Value = My.Computer.Name
cmdUlozit.Parameters.Add(parNazevSoftwaru)
cmdUlozit.Parameters.Add(parNazevPolozky)
cmdUlozit.Parameters.Add(parHodnotaPolozky)

For Each jmeno In reg.GetSubKeyNames
Dim nazev As RegistryKey = Registry.LocalMachine.OpenSubKey(cesta & "\" & jmeno)
Dim polozky() As String = nazev.GetValueNames

For Each p In polozky

If Object.ReferenceEquals(nazev.GetValue(p).GetType, GetType(System.String)) Then

Me.hledejNazev = p

If Me.nazvy.Exists(AddressOf Me.najdiNazevPolozky) = True Then

parNazevSoftwaru.Value = jmeno
parNazevPolozky.Value = p
parHodnotaPolozky.Value = nazev.GetValue(p, String.Empty).ToString

cmdUlozit.ExecuteNonQuery()

End If
End If
Next
Next


after several execute commands comes this error:

{"ERROR: 22021: invalid byte sequence for encoding "UTF8": 0x00"}


The errorsql string in debug details is:
select * from uloz_hodnoty(((E'NTB20')::text), ((E'{90120000-0015-0405-0000-0000000FF1CE}_PROHYBRIDR_{3FD35521-B8F1-4CE0-85E0-DC6CA1E01012}')::text), ((E'Publisher')::text), ((E'Microsoft\0H')::text))

i see here the last parameter value is with \0H.

i hope i haved not overlooked

Best regards

Followup

Message
Date: 2012-03-12 02:25
Sender: Francisco Figueiredo jr.


Hmmmmm, Npgsql should be formatting the backslash to double backslash.

So you should be seeing ((E'Microsoft\\0H')::text)) instead of single backslash.

I'll make some tests to see if I can reproduce the bug and fix it.

Sorry for that.

Attached Files:

Changes:

Field Old Value Date By
summary{"ERROR: 22021: invalid byte sequence for encoding "UTF8": 0x00"}2012-03-12 02:25fxjr
Powered By FusionForge