Solved

kretzschmar ..I try to used Steam but failed.

Posted on 2002-03-30
6
331 Views
Last Modified: 2010-05-18
hi...HELP
  look at this:

 ParamByName('Content').asBlob:=LString;

in this case ,the LString size is over 256 charactors.when storing LString to 'Content',delphi trimed the charactor >256.....
How to store the whole LSting to 'Content'???

Actually, this problem occurs when I convert a table from
FoxPro 2.6 Dos version to MS Sql Server 7.0.
the data field "Content" in Foxpro is MEMO.
the data field "MSSqlContent" in MSSQL is VarChar(2000).
when i use
 ParamByName('MsSqlContent').asString:=Query1Content.asString;

it shows Error Message the is
"BDEengine ERROr...General SQL Error..."
"Unclosed quotation mark before the Character string 'XX?)
Line 1:Incorrect Syntax Error near 'XX?) "


So I use ParamByName('MSSQLContent').asBLOB:=....; instead.
but the result is just as the question posted at first.

Now  I find that the problem is the LENGTH of the fox MEMO field.....
I can't save String( lenght>255) into the SQL SERVER 7.0 VARCHAR(2000) field ???????????????
WHY????????????????????????????????
HOW TO put a string ( length>255) int to the MS SQL SERVER 7.0 VARCHAR field ..
I try to used Stream but it failed again, cause ONLY 255 character saved into the VARCHAR(2000) field
,other Character (>255) has been Trimmed!!!
0
Comment
Question by:windyui
  • 3
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 6908559
var m : tmemorystream;
begin
  m := tmemorystream.create;
  TBlobField(foxprotable.fieldByName('Memo')).savetostream(m);  //assuming the table is open and on the record
  m.position := 0; //spool back
  //1->if you have a ttable on your mssql-side
  mssqltable.edit;
  TBlobField(mssqltable.fieldbyname('FieldName')).loadfromstream(m);
  mssqltable.post;
  //2->if you have a query with parameters, the parameter should defined as blob-parameter
  updatequery.parambyname('PramaName').loadfromstream(m);
  updatequery.execsql;
  m.free;
end;

hope this helps

meikl ;-)
0
 

Author Comment

by:windyui
ID: 6911734
HELP,
   I guess the problem is the BDE!!!I just try to input charactor over 256 into the Field(VARCHAR(2000)) directly inside BDE but failed!!!!Even I used CHAR(2000) I can't input any char over 255.
    I can't input charactor length over 255 inside the BDE.
What's the problem???I use Delphi 4.0 and MSSQL 7.0.
    I have tried all the possible ways to ExecSql by all failed, includes String and Stream.When I used string,General SQL Error occured. When I used Stream ,It trim the Charactor length over 255.
    Is it a bug of BDE???????????/or sth else I don't know.
I Do need to solve this problem ,PLEASE HELPME. >_<
                                                winyui T_T
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6912800
? a varchar(2000) should be recognized as blob-field by the bde

isn't it so?

meikl ;-)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:windyui
ID: 6912962
^^GREAT!! U r right!!
  My friends said that the problem is about the MS SQL driver for BDE.It can't deal with charactor length over 255,or the charactor will be CUT to 255.
  is there any other way to save the char(over 255) to a MSSQL field???????
(Divide the field to 8 Char(255)??????????)  >_<
  I have tried your TMemoryStream...But!! It Cut again! >_<
TOO BAD~~~~~~~!!! T_T
  Thank you for helping me so much.
                                     Windyui.
0
 

Expert Comment

by:jonnyfive
ID: 6915484
I would suggest to use ADO instead the BDE in this case.

Regards, Jonny...
0
 

Author Comment

by:windyui
ID: 6917383
...
Thanks all. especial kretzschmar ,thank you very MUCH.
the porblem is solved when I use ODBC.
  SORRY!!! I have not experience that I should not use BDE directly.!!!
  THANK YOU For your help.
  ^_^
  thankyou.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now