Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread wideString and bytes type
Fri, May 12 2006 10:17 AMPermanent Link

"Davide"
hi,

i'm using BCB5 and DBISAM 4, i need to store a widestring in a database
field, i decided
to use bytes type.

when i try to write the field if I use the TField methods all are ok:

  WideString w;
  w= TntEdit1->Text;
  DBISAMTable1->Open();
  DBISAMTable1->Insert();
  DBISAMTable1->Fields->Fields[0]->SetData( w.c_bstr(), true);
  DBISAMTable1->Post();

but i need to use a Query and i have problems...

   WideString w;
   w= TntEdit1->Text;
   try {
         q= query2;
         q->Close();
         q->SQL->Clear();
         q->SQL->Add( AnsiString().sprintf( "INSERT INTO table1 (campo1)
VALUES( :Pparam)"));
         q->ParamByName( "Pparam")->Value= Variant( w.c_bstr());
         q->ParamByName( "Pparam")->DataType= ftBytes;
or
         q->ParamByName( "Pparam")->SetData( w.c_bstr() );
         q->ExecSQL();
   } catch(...){}

don't works !!

can someone help me ? about the INSERT of a widestring in a DBISAM - BYTES
field ??

thanks.
Davide.



Fri, May 12 2006 4:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Davide,

<< don't works !! >>

What doesn't work ?  Does nothing get stored in the field ?  Or is there an
error ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, May 13 2006 4:59 PMPermanent Link

Dan Rootham
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Davide,

<< don't works !! >>

What doesn't work ?  Does nothing get stored in the field ?  Or is there an
error ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, May 13 2006 5:12 PMPermanent Link

Dan Rootham
Davide,

Try googling ftBytes + DataType. This is what I found on the first hit:
<< the TParams object doesn't support ftBytes datatype (supported by TField) >>

And I've also come across the ridiculous problem where an ADO query with a SQL.Text
property defined as type widestring does NOT support field values which are widestring.
In that case the *only* way round it was to pass the widestring values in as parameters.
Not DBISAM in that case, but Ingres...

But here I think your problem is with the parameter type itself.

Some days I just wish that the computer industry had evolved in China or Hungary
(and not in the USA), so that we wouldn't have these frustrating alphabet/language
support problems....

Regards,
Dan
Sun, May 14 2006 3:47 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Dan


>Some days I just wish that the computer industry had evolved in China or Hungary
>(and not in the USA), so that we wouldn't have these frustrating alphabet/language
>support problems....

But could you cope with a 20 foot wide keyboard - maybe a bit smaller but have you seen some of the native language keyboards for typewriters in Japan / China?

Roy Lambert
Mon, May 15 2006 4:26 AMPermanent Link

"Davide"
hi Tim,

in this case:
         q->Close();
         q->SQL->Clear();
         q->SQL->Add( AnsiString().sprintf( "INSERT INTO table1 (campo1)
VALUES( :Pparam)"));
         q->ParamByName( "Pparam")->Value= Variant( w.c_bstr());
         q->ParamByName( "Pparam")->DataType= ftBytes;
         q->ExecSQL();

i haven't error message, but when read the field this is empty...
"\0,\0,0,\0" in wchat_t array
(is difficult to debug a byte field with Database System Utility, no export
method available..)

i read the field in this two ways..
      wchar_t wchar[100];
      DBISAMTable1->Open();
      DBISAMTable1->Last();
      DBISAMTable1->Fields->Fields[0]->GetData( wchar, true);
     TntEdit1->Text= WideString( wchar);
or...
     q->Close();
     q->SQL->Clear();
     q->SQL->Add( AnsiString().sprintf( "SELECT * FROM table1" ));
     q->Open();
     q->Last();
     q->Fields->FieldByName( "campo1" )->GetData( wchar, true);
     TntEdit1->Text= WideString( wchar);


second case:
         q->ParamByName( "Pparam")->DataType= ftBytes;
         q->ParamByName( "Pparam")->SetData( w.c_bstr() );

i have this error:
       Project Projectt1.exe raised exception class EDatabaseError with
message 'query 2: Field 'Pparam' is
        of an unsupported type' Process stoppped..

Davide..


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel
messaggio news:56907EE6-DD59-43AA-9C02-090C0FEB7134@news.elevatesoft.com...
> Davide,
>
> << don't works !! >>
>
> What doesn't work ?  Does nothing get stored in the field ?  Or is there
> an error ?
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
>

Mon, May 15 2006 4:43 AMPermanent Link

"Davide"

"Dan Rootham" <roothamd@yahoo.co.uk> ha scritto nel messaggio
news:7F7D31A8-ECFB-4AAC-967A-C3243685ECAE@news.elevatesoft.com...
> Davide,
>
> Try googling ftBytes + DataType. This is what I found on the first hit:
> << the TParams object doesn't support ftBytes datatype (supported by
> TField) >>
>
thanks.. i read..

> And I've also come across the ridiculous problem where an ADO query with a
> SQL.Text
> property defined as type widestring does NOT support field values which
> are widestring.
> In that case the *only* way round it was to pass the widestring values in
> as parameters.
> Not DBISAM in that case, but Ingres...
>
> But here I think your problem is with the parameter type itself.
>
> Some days I just wish that the computer industry had evolved in China or
> Hungary
> (and not in the USA), so that we wouldn't have these frustrating
> alphabet/language
> support problems....
this is good.. but i need to made a software for international label food
package..
so i must menage unicode chars..

> Regards,
> Dan
>

Mon, May 15 2006 5:10 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Davide,

<< second case:
         q->ParamByName( "Pparam")->DataType= ftBytes;
         q->ParamByName( "Pparam")->SetData( w.c_bstr() );

i have this error:
       Project Projectt1.exe raised exception class EDatabaseError with
message 'query 2: Field 'Pparam' is of an unsupported type'  >>

Okay, the problem is that the TDBISAMParam.SetData method doesn't handle the
ftBytes type.  I will make sure this is corrected in the next build.  A
workaround is to set the data as a string using AsString and then change the
DataType to ftBytes afterward.  That should get around the problem.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, May 17 2006 3:02 AMPermanent Link

"Davide"
hi Tim,

now i solve the problem using: AssignField( TField) in TParam;

first i made the SLQ query whit a param ("parX" ) in the command
then i use a Table, i add a TField, loiad it whit:
        t->Fields->Fields[0]->SetData( bstr, true);
then:
       qIns->ParamByName( "parX")->AssignField( t->Fields->Fields[0]);

thanks.
Davide.


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel
messaggio news:0F2B17AA-D594-47EC-8EEB-F096710B1057@news.elevatesoft.com...
> Davide,
>
> << second case:
>          q->ParamByName( "Pparam")->DataType= ftBytes;
>          q->ParamByName( "Pparam")->SetData( w.c_bstr() );
>
> i have this error:
>        Project Projectt1.exe raised exception class EDatabaseError with
> message 'query 2: Field 'Pparam' is of an unsupported type'  >>
>
> Okay, the problem is that the TDBISAMParam.SetData method doesn't handle
> the ftBytes type.  I will make sure this is corrected in the next build.
> A workaround is to set the data as a string using AsString and then change
> the DataType to ftBytes afterward.  That should get around the problem.
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
>

Mon, Jan 19 2015 10:18 AMPermanent Link

Davide

hello,
at that time, to insert a BYTES type parameter,  i found this solution :

         char buf[MAX_WCHAR_LEN];   \\ my buffer data

         // insert 'buf' into FIELD of memory table
         t= tableByte;
         t->Close();
         t->TableName= "\\memory\\byteTable";
         t->Open();
         t->Insert();
         t->Fields->Fields[0]->SetData( buf, true);

         // copy FIELD from memory table into my query Param
         qIns->ParamByName( param)->DataType= ftBytes;
         qIns->ParamByName( param)->AssignField( t->Fields->Fields[0] );

         t->Close();
         t->EmptyTable();

where \\memory table was:
         CREATE TABLE IF NOT EXISTS \"\\memory\\byteTable\"( b bytes(200) );

after that i'm upgradig the software to BDS2009 and the database into 4.30 ad all was ok.

I have now updated DBISAM from 4.30 to 4.40 and the parameter don't be loadad..
can you help me?
where is the difference from 4.30 and 4.40 for this commands, and is there a escape solution?

Thanks.
Davide.


"Davide" wrote:

hi Tim,

now i solve the problem using: AssignField( TField) in TParam;

first i made the SLQ query whit a param ("parX" ) in the command
then i use a Table, i add a TField, loiad it whit:
        t->Fields->Fields[0]->SetData( bstr, true);
then:
       qIns->ParamByName( "parX")->AssignField( t->Fields->Fields[0]);

thanks.
Davide.


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel
messaggio news:0F2B17AA-D594-47EC-8EEB-F096710B1057@news.elevatesoft.com...
> Davide,
>
> << second case:
>          q->ParamByName( "Pparam")->DataType= ftBytes;
>          q->ParamByName( "Pparam")->SetData( w.c_bstr() );
>
> i have this error:
>        Project Projectt1.exe raised exception class EDatabaseError with
> message 'query 2: Field 'Pparam' is of an unsupported type'  >>
>
> Okay, the problem is that the TDBISAMParam.SetData method doesn't handle
> the ftBytes type.  I will make sure this is corrected in the next build.
> A workaround is to set the data as a string using AsString and then change
> the DataType to ftBytes afterward.  That should get around the problem.
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
>
Image