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 Chris Miller 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)

Status
Not open for further replies.

Mukesh Khandelwal

Programmer
Oct 19, 2005
28
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.

Enabling to use the RTF RichText control is a whole different topic and not done with any simple conversion. I don't think you could get to searchable RTF text and would store RTF in varbinary fields, even though it's kind of a text based encoding like HTML is.
 
Last edited:
hi

i used SYS(987,.T.) before inserting data to SQL,

when i used the same data from SQL then Chinease character are coming as "?????"

do i need to add N'chinese text' while uploading data

Thanks for the suggestions
 
Perhaps a repetition and summary of things I already said helps you understand.

SYS(987,.T.) will not enable you to use all Unicode characters in VFP it just converts bidirectional from the ANSI codepages VFP supports with Chinese symbols and Latin alphabet (for example English) to Unicode when it's forwarded to MSSQL by an insert/update and back from Unicode in nvarchar fields to the ANSI codepages VFP can handle from a select query.

If you want more than that you have to use Unicode controls, but a Rich Textbox Control is no such control.

In https://www.west-wind.com/presentations/foxunicode/foxunicode.html#DesktopInterface Rick Strahl uses the DataDynamics SharpGrid and the Microsoft Forms Editbox ActiveX controls. dbi is one vendor that was providing ActiveX controls with VFP support, I can't recommend anything that's up to date now, but one thing is sure: You'll have to purchase something that's doing Unicode and you won't be able to use VFPs core simple controls handling with controlsource.

The Rich Textbox control supports pasting in Unicode characters, but as you see it's causing fatal errors, if you feed it wrongly. the content of that control is RTF, not Unicode and is best stored in varbinary fields, which could solve the problem to have a free available and redistributable control, but you'll not be happy with the MSSQL data you get from this in terms of being able to search for text, as RTF is not purely the text.
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top