Solved

kretzschmar ..I try to used Steam but failed.

Posted on 2002-03-30
6
333 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Delphi cmd execution 6 60
how to update exe applicatio from internet ? 6 78
DBGrid or StringGrid ? 6 89
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

810 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