Hi!!!
I am using Delphi 7.0 with your ZComponent to connect PostgreSQL.
When I query table has 1 field which have data : '\\th-svr01\soft' so I receive '\th-svr01・t'.
is there any body show me to fix this bug ?
ps: I insert into that table by UTF8string.
Thanks a lot
special character("\")
Moderators: gto, cipto_kh, EgonHugeist
Hi tqtrung,
Although I have not directly used Postgress, I do have the same problem on MS SQL and MySQL.
The problem you are experiencing is common to many SQL databases, and it relates to the fact that the backslash character ('\') is normally a reserved character within their dbms.
There are a number of solutions to resolving it, but the one I use is to insert two backslashes which gets interpreted as one backslash by the SQL database.
For example, you could use the Delphi function AnsiReplaceStr() to replace all instances of '\' with '\\'. This will work for any string that contains one or more '\' chars. It even works for network paths, as it will swap '\\' to be '\\\\'.
When you insert two backslashes into a Database String field, this is commonly interpreted as a single backslash.
MyString := AnsiReplaceStr(MyString, '\', '\\');
For more information, you can check the DelphiBasics website:
http://www.delphibasics.co.uk/RTL.asp?N ... ReplaceStr
I hope that helps,
Chris
Although I have not directly used Postgress, I do have the same problem on MS SQL and MySQL.
The problem you are experiencing is common to many SQL databases, and it relates to the fact that the backslash character ('\') is normally a reserved character within their dbms.
There are a number of solutions to resolving it, but the one I use is to insert two backslashes which gets interpreted as one backslash by the SQL database.
For example, you could use the Delphi function AnsiReplaceStr() to replace all instances of '\' with '\\'. This will work for any string that contains one or more '\' chars. It even works for network paths, as it will swap '\\' to be '\\\\'.
When you insert two backslashes into a Database String field, this is commonly interpreted as a single backslash.
MyString := AnsiReplaceStr(MyString, '\', '\\');
For more information, you can check the DelphiBasics website:
http://www.delphibasics.co.uk/RTL.asp?N ... ReplaceStr
I hope that helps,
Chris