Saving long strings into sqlserver

General discussion forum about all databases other than SqlBase.
RogerArmstrong

Saving long strings into sqlserver

Post by RogerArmstrong » 28 May 2008, 02:22

TD 5.1 PTF2 . SqlServer 2000 SP3

When we try to write a longstring field to a ntext field on sqlserver we get the following error indicating a length mismatch.

" Number: 20029 Error Command: C:\Program Files\Unify\Team Developer 5.1\error.sql Error was [Microsoft][ODBC SQL Server Driver]String data, length mismatch "

If we change the source definition and make the subject eg sText of the insert just a string , then the insert works . We have tried setting the long type first but it seems to make no difference.

Call SqlPrepareAndExecute(hSql, ' DELETE FROM LS_TABLE ' )
If SqlPrepare ( hSql, ' INSERT INTO LS_TABLE ( LS_TEXT ) VaLUES ( :sText ) ' )
If SqlSetLongBindDatatype( 5, 22)
If SqlExecute(hSql)
Call SalMessageBox( 'Success' , ' inserted' , MB_Ok)
Else
Call SalMessageBox( 'Failed on Execute ' , ' inserted' , MB_Ok)
Else
Call SalMessageBox( 'Failed on Set Long data type ' , ' inserted' , MB_Ok)
Else
Call SalMessageBox( 'Failed on Prepare ' , ' inserted' , MB_Ok)
Call SqlCommit(hSql)
Call SqlDisconnect ( hSql)


DOes anyone know if this is a permanent change , eg to use strings and not longstring !

cheers RWA

Jean-Marc Gemperle

Re: Saving long strings into sqlserver

Post by Jean-Marc Gemperle » 28 May 2008, 15:41

Hi Roger,

Do I understand you well you are saying you have problem if you use LONG STRING and NOT STRING is that correct?
If that the case this is in contradiction of the CCOD.PDF manual in TD 5.1 page 3-3. We don't talk about NTEXT but would assume it be the same as with TEXT
here it says

LONG STRING
BINARY (8000 or fewer bytes)
CHAR (8000 or fewer bytes)
IMAGE
TEXT
VARBINARY (8000 or fewer bytes)
VARCHAR (8000 or fewer bytes)
DOes anyone know if this is a permanent change , eg to use strings and not longstring !
Good question, if that would be the manual would get a bug...
so let me check that...

Cheers
JM

Jean-Marc Gemperle

Re: Saving long strings into sqlserver

Post by Jean-Marc Gemperle » 28 May 2008, 15:51

Hi again,

Normally SqlSetLongBindDatatype( 5, 22) is not needed AFAIK for TEXT as it is the default...
I assume you try without?

JM

RogerArmstrong

Re: Saving long strings into sqlserver

Post by RogerArmstrong » 28 May 2008, 23:29

HI JM

Yes what I am saying that if i use a longstring when trying to insert a record I get the error . If I just use a string I dont get the error and the insert works - even if the string is > 4000 bytes.

If I set the parameter it doesnt make any difference - with a long string it still doesnt work - with a string it works with or without the parameter.

The manual indicates that I should be using a longstring

I attached a small test app
Testls51.zip
cheers Roger
You do not have the required permissions to view the files attached to this post.

Jean-Marc Gemperle

Re: Saving long strings into sqlserver

Post by Jean-Marc Gemperle » 29 May 2008, 14:14

Hi,

Just to let you know I'm looking into this and see indeed problem...but also with TD 4.2 and this confuses me.
I should let you know soon. I'm using curretnly my own testcase with OLEDB no problem with ODBC I have odd issues...
I will check your testcase as well. The question though, is assuming you can insert with STRING up to 4000 which I could test indeed....
Are you sure your data inserted are OK, also can you fecht with long strings? this is where I have problem, don't you have any truncations?

JM

Jean-Marc Gemperle

Re: Saving long strings into sqlserver

Post by Jean-Marc Gemperle » 30 May 2008, 13:55

Hi

I entered TD-4727 for this issue.

Thanks for your report.

JM

wilhelm
Germany
Posts: 282
Joined: 22 Mar 2017, 08:49
Location: Cologne

Re: Saving long strings into sqlserver

Post by wilhelm » 13 Aug 2013, 09:53

I know, this is an very old thread, but I just came across this error when updateing our 4.1 application with the sqlncli drivers for SQLServer 2008.
Have there been any fixes to this error?

Thanks in advance

Wilhelm

sudhakaruki

Re: Saving long strings into sqlserver

Post by sudhakaruki » 26 Sep 2013, 11:14

Hi,

In SqlSetLongBindDatatype( nBindVarNumber,nDatatype ) wes should give the nBindVarNumber correctly.

Use 1 to set the first bind variable and 2 for second variable and so on..

i hope may be this will be wrong.

And also check there is no other sql statements not runs.


Regards
Sudhakar G

wilhelm
Germany
Posts: 282
Joined: 22 Mar 2017, 08:49
Location: Cologne

Re: Saving long strings into sqlserver

Post by wilhelm » 26 Sep 2013, 19:03

Sorry, but I really don't understand what you are trying to say.

Wilhelm

sudhakaruki

Re: Saving long strings into sqlserver

Post by sudhakaruki » 27 Sep 2013, 10:06

Hi,
Sorry
at first please check the parameters of SqlSetLongBindDatatype( nBindVarNumber,nDatatype ). and give it correctly or is it possible to show your sample code?


regards
Sudhakar G

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests