Board index » delphi » Help......Moving Data from Clipboard to Dataset/DBGrid

Help......Moving Data from Clipboard to Dataset/DBGrid

Hi,

I was just wondering what is the easiest way to move data that is in
the clipboard (CSV format) to a database table....

I can change the data to an array, etc. but I'm unclear at a quick way
to populate a table...

Thanks for the help,
james

 

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Hi,

I was just wondering what is the easiest way to move data that is in
the clipboard (CSV format) to a database table....

I can change the data to an array, etc. but I'm unclear at a quick way
to populate a table...

Thanks for the help,
james

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


James,

check my SMImport suite:
http://www.scalabium.com/smi

--
With best regards, Mike Shkolnik
E-mail: [email protected]
WEB: http://www.scalabium.com

Quote
<james> wrote in message news:[email protected]
> Hi,

> I was just wondering what is the easiest way to move data that is in
> the clipboard (CSV format) to a database table....

> I can change the data to an array, etc. but I'm unclear at a quick way
> to populate a table...

> Thanks for the help,
> james

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Hello James,

The signature is the message <g>

--
Andrei Fomine    www.quasidata.com
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
[email protected] - full-blown clipboard and drag-and-drop data transfer
to/from any control in many formats, including ones native to MS Office.

Quote
<james> wrote in message news:[email protected]
> Hi,

> I was just wondering what is the easiest way to move data that is in
> the clipboard (CSV format) to a database table....

> I can change the data to an array, etc. but I'm unclear at a quick way
> to populate a table...

> Thanks for the help,
> james

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


First get a handle to your clipboard data:

Handle:= Clipboard.GetAsHandle(CF_TEXT);

(I am assuming here that your clipboard data is stored as text.)

Next get a pointer to the data:

Ptr := GlobalLock(Handle);

Next create a blobStream and write your data to the stream:

Stream.WriteBuffer(Ptr^, GlobalSize(Handle));

You will be storing this is a field that has a LoadfromStream method I
assume <g>.

Bob
---
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Thanks Bob,

I'll give it a try this weekend...Will let you know the results.

james

On Fri, 20 Sep 2002 21:24:14 +0100, Bob Villiers

Quote
<[email protected]> wrote:
>First get a handle to your clipboard data:

>Handle:= Clipboard.GetAsHandle(CF_TEXT);

>(I am assuming here that your clipboard data is stored as text.)

>Next get a pointer to the data:

>Ptr := GlobalLock(Handle);

>Next create a blobStream and write your data to the stream:

>Stream.WriteBuffer(Ptr^, GlobalSize(Handle));

>You will be storing this is a field that has a LoadfromStream method I
>assume <g>.

>Bob
>---
>Sent using Virtual Access 5.01 - download your freeware copy now
>http://www.atlantic-coast.com/downloads/vasetup.exe

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Thanks Bob,

I'll give it a try this weekend...Will let you know the results.

james

On Fri, 20 Sep 2002 21:24:14 +0100, Bob Villiers

Quote
<[email protected]> wrote:
>First get a handle to your clipboard data:

>Handle:= Clipboard.GetAsHandle(CF_TEXT);

>(I am assuming here that your clipboard data is stored as text.)

>Next get a pointer to the data:

>Ptr := GlobalLock(Handle);

>Next create a blobStream and write your data to the stream:

>Stream.WriteBuffer(Ptr^, GlobalSize(Handle));

>You will be storing this is a field that has a LoadfromStream method I
>assume <g>.

>Bob
>---
>Sent using Virtual Access 5.01 - download your freeware copy now
>http://www.atlantic-coast.com/downloads/vasetup.exe

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Here is some code for transferring a JPeg file from the clipboard to a
blob field which you can adapt.

//Transfer JPeg in Clipboard to Blob Field
procedure TForm1.Button6Click(Sender: TObject);
var
  DataPtr: Pointer;
  MemStream: TMemoryStream;
  Data: THandle;
begin
  if Clipboard.HasFormat(CF_JPEG) then
  begin
    Clipboard.Open;
    try
      Data:= Clipboard.GetAsHandle(CF_JPEG);
      DataPtr := GlobalLock(Data);
      try
        MemStream := TMemoryStream.Create;
        try
          MemStream.WriteBuffer(DataPtr^, GlobalSize(Data));
          Table1.Append;
          Table1GRAPHIC.LoadFromStream(memStream);
          Table1.Post;
        finally
          memStream.Free;
        end;
      finally
        GlobalUnlock(Data);
      end;
    finally
      Clipboard.Close;
    end;
  end;
end;

Bob
---
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:Help......Moving Data from Clipboard to Dataset/DBGrid


Well... now you've gone and made it easy for me! <bg>

thanks again....i'll use it
james

On Sat, 21 Sep 2002 07:26:10 +0100, Bob Villiers

Quote
<[email protected]> wrote:
>Here is some code for transferring a JPeg file from the clipboard to a
>blob field which you can adapt.

>//Transfer JPeg in Clipboard to Blob Field
>procedure TForm1.Button6Click(Sender: TObject);
>var
>  DataPtr: Pointer;
>  MemStream: TMemoryStream;
>  Data: THandle;
>begin
>  if Clipboard.HasFormat(CF_JPEG) then
>  begin
>    Clipboard.Open;
>    try
>      Data:= Clipboard.GetAsHandle(CF_JPEG);
>      DataPtr := GlobalLock(Data);
>      try
>        MemStream := TMemoryStream.Create;
>        try
>          MemStream.WriteBuffer(DataPtr^, GlobalSize(Data));
>          Table1.Append;
>          Table1GRAPHIC.LoadFromStream(memStream);
>          Table1.Post;
>        finally
>          memStream.Free;
>        end;
>      finally
>        GlobalUnlock(Data);
>      end;
>    finally
>      Clipboard.Close;
>    end;
>  end;
>end;

>Bob
>---
>Sent using Virtual Access 5.01 - download your freeware copy now
>http://www.atlantic-coast.com/downloads/vasetup.exe

Other Threads