🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
5 messages
5 total messages Started by Foo Tze Wan Tue, 23 Aug 2005 09:33
TADOCommand and Blob
#497
Author: Foo Tze Wan
Date: Tue, 23 Aug 2005 09:33
55 lines
2774 bytes
Hi,

I am using BCB6 to read and write data to Interbase. The ODBC driver used is 
from Easysoft (trial version). I have tried to write to the table.

Without the Blob field (BLOB_FIELD), it works fine. But when I include the 
Blob field, an EOleException - "Type is Invalid" is raised upon Execute( ).

Wonder if anyone has any clue on what could be wrong ( I suspect is the 
driver, but cannot confirm).

The following is a snippet of my code.

{
            TMemoryStream *mem_stream_ptr;
            AnsiString    sql_command_string;

            mem_stream_ptr = new TMemoryStream();

            sql_command_string = AnsiString("INSERT INTO USER_TABLE (USERID, 
DEPARTMENT, BLOB_FIELD) ") +
                                         "VALUES (:pUserID, :pDepartment, 
:pBlobField)";

            ADOCommandUser->CommandText = sql_command_string;

            ADOCommandUser->Parameters->ParamByName("pUserID")->DataType = 
ftString;
            ADOCommandUser->Parameters->ParamByName("pDepartment")->DataType 
= ftString;
            ADOCommandUser->Parameters->ParamByName("pBlobField")->DataType 
= ftBlob;

            ADOCommandUser->Parameters->ParamByName("pUserID")->Value = 
"1234";
            ADOCommandUser->Parameters->ParamByName("pDepartment")->Value = 
"Finance";

            mem_stream_ptr->WriteBuffer(BlobFieldArray, 4856); // The size 
of the blob field is as such.

            // BlobFieldArray is a global, declared as --> unsigned char 
BlobFieldArray[5000];

            mem_stream_ptr->Position = 0;
            mem_stream_ptr->Seek(0, soFromBeginning);
            ADOCommandFPUser->Parameters->ParamByName("pFP")->LoadFromStream(mem_stream_ptr, 
ftBlob);
            ADOCommandFPUser->Execute();
}

Appreciate any help.

Thanks and regards,
Tze Wan 
Re: TADOCommand and Blob
#499
Author: Viatcheslav V. Vassiliev
Date: Tue, 23 Aug 2005 18:44
79 lines
3658 bytes
There are few native OLEDB providers for Interbase such as one from 
http://www.ibprovider.com, or google for "Interbase OLEDB". OLEDB provider 
for ODBC is deprecated, and native OLEDB providers are usually better work 
and have less problems.

You may also try to set type to something like ftVarBytes.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + 
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Foo Tze Wan" <twfoo@nospam.com> �������/�������� � �������� ���������: 
news:430aed68@newsgroups.borland.com...
> Hi,
>
> I am using BCB6 to read and write data to Interbase. The ODBC driver used 
> is
> from Easysoft (trial version). I have tried to write to the table.
>
> Without the Blob field (BLOB_FIELD), it works fine. But when I include the
> Blob field, an EOleException - "Type is Invalid" is raised upon 
> Execute( ).
>
> Wonder if anyone has any clue on what could be wrong ( I suspect is the
> driver, but cannot confirm).
>
> The following is a snippet of my code.
>
> {
>            TMemoryStream *mem_stream_ptr;
>            AnsiString    sql_command_string;
>
>            mem_stream_ptr = new TMemoryStream();
>
>            sql_command_string = AnsiString("INSERT INTO USER_TABLE 
> (USERID,
> DEPARTMENT, BLOB_FIELD) ") +
>                                         "VALUES (:pUserID, :pDepartment,
> :pBlobField)";
>
>            ADOCommandUser->CommandText = sql_command_string;
>
>            ADOCommandUser->Parameters->ParamByName("pUserID")->DataType =
> ftString;
> 
> ADOCommandUser->Parameters->ParamByName("pDepartment")->DataType
> = ftString;
>            ADOCommandUser->Parameters->ParamByName("pBlobField")->DataType
> = ftBlob;
>
>            ADOCommandUser->Parameters->ParamByName("pUserID")->Value =
> "1234";
>            ADOCommandUser->Parameters->ParamByName("pDepartment")->Value =
> "Finance";
>
>            mem_stream_ptr->WriteBuffer(BlobFieldArray, 4856); // The size
> of the blob field is as such.
>
>            // BlobFieldArray is a global, declared as --> unsigned char
> BlobFieldArray[5000];
>
>            mem_stream_ptr->Position = 0;
>            mem_stream_ptr->Seek(0, soFromBeginning);
> 
> ADOCommandFPUser->Parameters->ParamByName("pFP")->LoadFromStream(mem_stream_ptr,
> ftBlob);
>            ADOCommandFPUser->Execute();
> }
>
> Appreciate any help.
>
> Thanks and regards,
> Tze Wan
>
> 
Re: TADOCommand and Blob
#500
Author: Foo Tze Wan
Date: Wed, 24 Aug 2005 10:04
18 lines
1460 bytes
Thanks Vassiliev for your reply again.

>> You may also try to set type to something like ftVarBytes.
This does not help either.

Instead of using TADOCommand, I tried TADODataSet, and its FieldByName(..) 
method, and I managed to get it work.

Regards,
Tze Wan

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
Re: TADOCommand and Blob
#629
Author: poojo hackma
Date: Wed, 02 Nov 2005 20:33
46 lines
2897 bytes
Foo Tze Wan:

Did you ever get this to work?  I am having a similar problem, and I can not 
find a solution.

I dropped a TADOCommand component onto my form and added these 11 parameters 
to the ADOCommand1->Parameters list:

DataType  Direction  Name  NumericScale  Precision  Size  Value
ftLargeint pdInput   pSP   0             9          0     (Null)
ftString   pdInput   pDe   0             0          50    (Null)
ftLargeint pdInput   pLe   0             9          0     (Null)
ftFloat    pdInput   pRs   10            20         0     (Null)
ftFloat    pdInput   pOs   10            20         0     (Null)
ftFloat    pdInput   pMn   10            20         0     (Null)
ftFloat    pdInput   pMx   10            20         0     (Null)
ftString   pdInput   pUt   0             0          7     (Null)
ftLargeint pdInput   pSp   0             9          0     (Null)
ftLargeint pdInput   pPG   0             9          0     (Null)
ftLargeint pdInput   pBt   0             9          0     (Null)

I have created my INSERT SQL command:

  ADOCommand1->CommandText =
    AnsiString("INSERT INTO SPNs (SPN, Desc, Len, Res, Ofs, ") +
    AnsiString(         "Min, Max, Unit, Sus, PGN, start) ") +
    AnsiString("VALUES (:pSP, :pDe, :pLe, :pRs, :pOs, ") +
    AnsiString(         ":pMn, :pMx, :pUt, :pSp, :pPG, :pBt)");


When I try to assign values to any of my Parameters like this:

  ADOCommand1->Parameters->ParamByName("pSP")->Value = 94;

I get the error: "ADOCommandUser: Parameter 'pSP' not found"

How do I get around this?

Have I set up my parameters incorrectly?

Would it help to set all of the DataTypes to ftVariant?

If I use ftVariant, how do I set up the other Parameter fields to accept 
integers, strings and doubles?

Poojo 
Re: TADOCommand and Blob
#534
Author: Mark Guerrieri
Date: Thu, 03 Nov 2005 22:14
17 lines
1470 bytes
Try the following-

First, clear all the parameters from your design-time parameter list.
Then...

ADOCommand1->CommandText =
  AnsiString("INSERT INTO SPNs (SPN, Desc, Len, Res, Ofs, ") +
  AnsiString(         "Min, Max, Unit, Sus, PGN, start) ") +
  AnsiString("VALUES (:pSP, :pDe, :pLe, :pRs, :pOs, ") +
  AnsiString(         ":pMn, :pMx, :pUt, :pSp, :pPG, :pBt)");

ADOCommand->Parameters->ParseSQL(ADOCommand->CommandText, true);
ADOCommand1->Parameters->ParamByName("pSP")->Value = 94;

...

Mark
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads