Re: String truncation in insert to SQL Server with DBD::ADO and place holders

From: Steffen Goeldner (sgoeldner_at_cpan.org)
Date: 09/20/04


Date: Mon, 20 Sep 2004 12:12:58 +0200
To: "Sarkissian, Vahe - NC" <Vahe.Sarkissian@cnb.com>


Steffen Goeldner wrote:

> Mysterious! Looks like the first execute establishes
> a sticky max. length in SQL Server.

Indeed, I can reproduce it with pure ADO (see attached script).
Unfortunately, I don't see a portable workaround for DBD::ADO.
I think it would be best the SQL Server team buys a Shared
Source License from the Access or FoxPro team - they know
how to do it ;-)

Steffen


use Win32::OLE;

$Win32::OLE::Warn = 2;

$cxn = Win32::OLE->new('ADODB.Connection');
$cxn->Open('Provider=SQLOLEDB;Trusted_Connection=Yes');
$cxn->BeginTrans;

my $cmd = Win32::OLE->new('ADODB.Command');
   $cmd->{ActiveConnection} = $cxn;
   $cmd->{CommandText} = 'insert into trunctest( s ) values( ? )';
# $cmd->{CommandType} = $e->{CommandTypeEnum}{adCmdText};
   $cmd->{Prepared} = 1;

$cmd->Parameters->Refresh;
print 'C: ', $cmd->Parameters->Count;

my $i = $cmd->Parameters->Item( 0 );
print 'T: ', $i->{Type};
print 'S: ', $i->{Size};

$i->{Size} = 4;
$i->{Value} = '1234';
$cmd->Execute;

$i->{Size} = 3;
$i->{Value} = '123';
$cmd->Execute;

$i->{Size} = 5;
$i->{Value} = '12345';
$cmd->Execute;

my $rs = $cxn->Execute('select * from trunctest');
while ( !$rs->{EOF} ) {
  print ' : ', $_->Value for Win32::OLE::in( $rs->Fields );
  $rs->MoveNext;
}
$rs->Close;

$cxn->RollbackTrans;
$cxn->Close;

=for test

C: 1
T: 200
S: 20
 : 1234
 : 123
 : 1234 <=== truncated!

=cut



Relevant Pages

  • RE: String truncation in insert to SQL Server with DBD::ADO and place holders
    ... > Steffen Goeldner wrote: ... I can reproduce it with pure ADO. ... > I think it would be best the SQL Server team buys a Shared ...
    (perl.dbi.users)
  • Re: Duplicate Values Question
    ... happened with the first release of ACE. ... has taken over development from the SQL Server team. ... thought of Jet as a toy and a competitor so they were not inclined to ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Whats My Password?
    ... SQL Server was written by Sybase in Berkley California. ... While "SQL Server" Compact Edition is now being worked on in India, ... its look and feel has to conform to Microsoft ... While the Visual Studio team and the SQL Server team have ...
    (microsoft.public.dotnet.framework.adonet)
  • Microsoft SQL Server 2005 JDBC Driver is released to the web -- JAN 18, 2005
    ... driver and is being tested against all major application servers including ... - Support for new SQL Server 2005 Data Types ... for improved JDBC connectivity and commitment from the SQL Server team. ...
    (microsoft.public.sqlserver.jdbcdriver)