Board index » delphi » Need help Editing a Text field using MS SQL 6.5

Need help Editing a Text field using MS SQL 6.5

I have a text field defined in a table. I use a SELECT * statement with
a where clause to retrieve one record in the table. I have RequestLive
:= True. I can edit all the fixed length fields using DBEdit controls.
However, if I use a DBMemo for the text field it won't let me edit the
text data. If I call post, i get a general SQL error.

Using Delphi 4.02 running on WIN98 with SQL 6.5 (SP3) on NT4.0 (SP4)
with BDE 5.01

Any sugesstions would be appreciated.

andy
an...@erols.com

 

Re:Need help Editing a Text field using MS SQL 6.5


Quote
andy wrote:

> I have a text field defined in a table. I use a SELECT * statement with
> a where clause to retrieve one record in the table. I have RequestLive
> := True. I can edit all the fixed length fields using DBEdit controls.
> However, if I use a DBMemo for the text field it won't let me edit the
> text data. If I call post, i get a general SQL error.

> Using Delphi 4.02 running on WIN98 with SQL 6.5 (SP3) on NT4.0 (SP4)
> with BDE 5.01

> Any sugesstions would be appreciated.

> andy
> an...@erols.com

Here is some Code I got from these forums at an ealier time on this
Topic. Author: Jim Carpenter / J-E.Carpen...@worldnet.att.net

The code is for retrieving, so adapting it for the reverse should not be
to hard.

<BEGIN>

function Load_blob_from_SQL(SQLStr : string;
   var Buffer : pChar; var BufferSize : Longint):boolean;
var
 DataSet : TQuery;
 result_Size : longint;
 result_buffer : pChar;
begin
 DataSet := TQuery.create(nil);
 DataSet.databasename := Utility_database.databasename;
 with DataSet.SQL do
 begin
  clear;
  add(SQLStr);
 end;
 DataSet.Open;
 if assigned(dataset) then
 try
  Result := false;
  Dataset.updatecursorpos;
  if buffer <> nil then
   Free_Buffer(buffer,BufferSize);

  check(dbiOpenBlob(Dataset.handle, Dataset.activebuffer,
Dataset.fieldbyname(fldMEMO).fieldNo, dbiReadOnly));
  try
   check(dbiGetBlobSize(Dataset.Handle, Dataset.ActiveBuffer,
Dataset.fieldbyname(fldMEMO).FieldNo,BufferSize));
   if (BufferSize < 1) or (BufferSize > 1024) then
   begin
    Buffer := nil;
    BufferSize := -1;
    exit;
   end;
   inc(buffersize);
   if Get_buffer(Buffer, Buffersize) then
   begin
    check(dbiGetBlob(Dataset.Handle, Dataset.ActiveBuffer,
Dataset.fieldbyname(fldMEMO).FieldNo, 0,
      BufferSize-1, buffer, result_size));
    result := true;
   if result_size < buffersize-1 then
   begin
    result_buffer := nil;
    inc(result_size);
    get_buffer(result_buffer, result_size);
    if result_buffer <> nil then
    begin
     result_buffer := StrLCopy(result_buffer, buffer,result_size-1);
     free_buffer(buffer,buffersize);
     buffer := result_buffer;
     bufferSize := result_size;
    end;
   end

   end
   else
    buffersize := -1;
  finally
   Check(dbiFreeBlob(Dataset.handle, Dataset.ActiveBuffer,
Dataset.fieldbyname(fldMEMO).FieldNo));
  end;
 finally
  dataset.free;
 end;
end;

<END>

HTH

Rkr

--

                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer                       .
. TVisualBasic:=class(None)               .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) home (dot) com    .
-------------------------------------------

Re:Need help Editing a Text field using MS SQL 6.5


Hi.

Quote
andy wrote in message <368BC3D3.D9858...@erols.com>...
>I have a text field defined in a table. I use a SELECT * statement with
>a where clause to retrieve one record in the table. I have RequestLive
>:= True. I can edit all the fixed length fields using DBEdit controls.
>However, if I use a DBMemo for the text field it won't let me edit the
>text data. If I call post, i get a general SQL error.

>Using Delphi 4.02 running on WIN98 with SQL 6.5 (SP3) on NT4.0 (SP4)
>with BDE 5.01

>Any sugesstions would be appreciated.

I think you need a unique index on the table.
Regards
Stig Johansen.

Other Threads