Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gives C0000005 error on strconv(memo string,14)

Mukesh Khandelwal

Programmer
Oct 19, 2005
27
IN
Hi
Application got crashed when i use strconv(memo string,14) to convert SQL nvarchar field to cursor MEMO field

i am showing the content in Rich text 32 control in foxpro

its hanging when i navigate 10-15 record
below is the screenshot
1732604919156.png

i am inserting below OLE object
1732605323953.png
 
Last edited:
What is in line 46 of navigaterecord?

Since you don't use an oleboundcontrol the way you added this Rich Textbox control, that means you set the TextRTF propertty, right? If you set it to something not RTF text that may cause the error. RTF also doesn't match with Unicode, so the overall construct seems wrong to me, using an nvarchar field in MSSQL to store RTF text.
 
RTF files and thus also the Rich Textbox Control are capable to store and display unicode, but not as unicode nor as unicode converted back to ANSI codepage, In short, open up Wordpad or Word, write omething including chinese or other Unicode and save that as RTF file, then open it up in Notepad or Notepad++, then you see an RTF representation that you could set to that controls TextRTF püroperty, but that's not Unicode.

So overall, I think you're better of with just an Editbox which displays Ansi you converted from nvarchar or you use a conversion to RTF that's not straight forward but would then allow markup of text, like italic, bold, etc. or you use another Unicode capable control supporting unicode directly.
 
Last edited:
Hi
My text may include Chinese text along with English. My application with native dbf files uses EDITBOX contro to save and display Chinese+English text , no issue there.

Recently i changed database to SQL so for storing data in SQL i used a nvarchar field and stored it as STRCONV(memo string,13)
While retrieving from SQL and display to richtx32 control i used TEXT property of the control and assign it as STRCONV(memo string,14)

after navigating few records(10-15) application gives me above error. if i commented the code of assigningas STRCONV(memo string,14) then there is no error.
 
STRCONV(x,13) and STRCONV(x,14) are for en/decoding to base64, not unicode, you're on the completely wrong track, even if you don't get errors now.
Unicode = STRCONV(Ansi,5) and ANSI = STRCONV(Unicode,6) are your conversions, but better make use of SYS(987), as recommended in your previous thread.

See your older thread. If you want to work with the MSSQL data, for example in Sql Server Management Studio and read the chinese in query result windows, for example, you have to convert to Unicode, nvarchar fields are for storing unicode and not at all for base64, base64 is only using some ascii characters and would better be stored in normal char/varchar fields. Besides, you could also store ansi without any conversion not using nvarchar.

If you want to use nvarchar and nchar you want to use unicode, neither base64 nor RTF. RTF isn't even a character encoding, it's a file format and even if you only talk about the character encoding within RTF text, the mere text portions, RTF will always work with some ANSI codepage and character escape sequences.
 
Last edited:
For sake of using SYS(987), try out this:

1. Form with Editbox1 and a text having English and Chinese in it
2. MSSQL table like this:
Code:
CREATE TABLE TestUnicode (
    id int IDENTITY(1, 1) NOT NULL primary key,
    TextColumn nvarchar(120))
2. Button click code:
Code:
SYS(987,.T.)
AnsiText = Thisform.EditBox1.Value
SQLEXEC(h,"Insert Into TestUnicode (TextColumn) VALUES (?m.AnsiText)")
Where h is the handle you got from SQLStringConnect or SQLConnect. Even better use updatable remote view or cursoradapter and TABLEUPDATE(), but that's for later.

Get back the text with
Code:
SYS(987,.T.)
SQLEXEC(h,"Select TextColumn From TestUnicode","crsSQLResult")
And then browse that cursor or set aneditbox.value to TextColumn.

But also, open up SQL Server Management Studio and list the table there or query Select TextColumn From TestUnicode there and see that you will be able to read the Unicode text there. That's neither possible with base64 encoded text nor with RTF.
You want to be able to search your texts, later with queries like Select TextColumn From TestUnicode WHERE TextColumn LIKE N'%search word (even chinese)%' or other queries. You'll only be able to do so converting to Unicode, nothing else.

You can also do the SYS(987,.T.) once in your start main.prg, it's not necessary to repeat it before every single SQLEXEC, but it does the conversion to and from Unicde automatically, you just have to use parameters in your SQL, not string literals, that won't work out due to several issues of which one is that of string delimiters I talked about in your other thread.

To use RTF you will need to convert Unicode to an RTF file, that's not doable with STRCONV(), indeed VFP has no inbuilt function for that, it's also not just a different character encoding, it's a file format. You can't even expect the RTF Textbox control to display the same ANSI text as a VFP Editbox when you set the Text property instead of TextRTF. If you want to get more than just the limited set of characters available in Ansi codepages VFP can display in its controls, then go for Unicode controls, not the RTF control, that's the wrong choice.

Enqabling to use the RTF RichText control is a whole different topic and not done with any simple conversion.
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top