Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AseBulkCopy throw exception

109 views
Skip to first unread message

Lespinoza

unread,
Jun 19, 2009, 4:44:08 PM6/19/09
to
Hi all,
I try to use the AseBulkCopy class to load a XML file with 325000
records to ASE 12.5.4 table from C# (VS2005) but this throw
System.InvalidCastException exception
with the message "Unable to cast object of type 'System.Int16' to type
'System.String'." but my XML and table only have string fields. Any
Idea?

bulkCopy.BatchSize = 1000;
bulkCopy.BulkCopyTimeout = 30;
bulkCopy.NotifyAfter = 1000;
bulkCopy.DestinationTableName = "CuotaAtrasada";
bulkCopy.WriteToServer(tableOfData);

The entire XML file was loaded into dataset and all fields are
System.String type

The source XML and the target table named "CuotaAtrasada" has the same
number, order and name of columns. This table has no primary key.
Following the table structure:

Database Options
select into/bulkcopy/pllsort, trunc log on chkpt

table structure
Create Table CuotaAtrasada
(
TipoPersona varchar(30) NULL
,IdDeudor varchar(30) NULL
,IdOperacion varchar(30) NULL
,TipoCuota varchar(30) NULL
,NumCuotaAtrasada varchar(30) NULL
,DiasAtraso varchar(30) NULL
,MontoCuotaAtrasada varchar(30) NULL
,id varchar(30) NULL
,accion varchar(30) NULL
,Datos_Id varchar(30) NULL
)

Paul Vero [Sybase]

unread,
Jun 22, 2009, 6:19:56 PM6/22/09
to
Hi,

I think this message is coming from something else, not the ASE since the
types indicated are ADO.NET types - Do you have a try / catch block in here
and
possibly add PrintStackTrace to this - it would give a good idea of where
this
is failing.

The error could have more to do with improper setting of a value to a
property
rather than something related to the XML data. Does it occur in the
beginning?
Do any records get inserted? Or does nothing happen in that regard?

Example:

try
{
//Bulk Copy code - like what you have below


bulkCopy.BatchSize = 1000;
bulkCopy.BulkCopyTimeout = 30;
bulkCopy.NotifyAfter = 1000;
bulkCopy.DestinationTableName = "CuotaAtrasada";
bulkCopy.WriteToServer(tableOfData);

}
catch (AseException asex)
{
Console.WriteLine("AseException: " + asex);
//Might not be necessary as AseException can produce the stack
Console.WriteLine("Stack: " + asex.StackTrace);
}


-Paul


"Lespinoza" <luisespi...@gmail.com> wrote in message
news:fc670c93-d344-4a74...@d7g2000prl.googlegroups.com...

Paul Vero [Sybase]

unread,
Jun 23, 2009, 11:06:07 AM6/23/09
to
Hi,

I think this message is coming from something else, not the ASE since the
types indicated are ADO.NET types - Do you have a try / catch block in here
and
possibly add PrintStackTrace to this - it would give a good idea of where
this
is failing.

The error could have more to do with improper setting of a value to a
property
rather than something related to the XML data. Does it occur in the
beginning?
Do any records get inserted? Or does nothing happen in that regard?

Example:

try
{
//Bulk Copy code - like what you have below

bulkCopy.BatchSize = 1000;
bulkCopy.BulkCopyTimeout = 30;
bulkCopy.NotifyAfter = 1000;
bulkCopy.DestinationTableName = "CuotaAtrasada";
bulkCopy.WriteToServer(tableOfData);

}


catch (AseException asex)
{
Console.WriteLine("AseException: " + asex);
//Might not be necessary as AseException can produce the stack
Console.WriteLine("Stack: " + asex.StackTrace);
}


-Paul


"Lespinoza" <luisespi...@gmail.com> wrote in message
news:fc670c93-d344-4a74...@d7g2000prl.googlegroups.com...

luisespinoza

unread,
Jun 23, 2009, 1:45:39 PM6/23/09
to
H
> > egroups.com... Hi all,

luisespinoza

unread,
Jun 23, 2009, 2:56:33 PM6/23/09
to
Paul,
the error occur when the sentence

bulkCopy.WriteToServer(tableOfData);

run, no data are sending to server and the table keep empty.
No records was inserted and the exception return this
information

Message

"Unable to cast object of type 'System.Int16' to type

'System.String'." string

Source
"Sybase.AdoNet2.AseClient" string

StackTrace "
at
Sybase.Data.AseClient.AseBulkCopy.GenerateInsertCmd(DataTable
rowFmt)\r\n
at
Sybase.Data.AseClient.AseBulkCopy.PrepareMetaInfo(DataTable
clientTableFmt)\r\n
at Sybase.Data.AseClient.AseBulkCopy.WriteToServer(DataTable
table)\r\n
at DataHelper.SybaseHelper.BulkCopyData(String dataBase,
String tableName, DataTable tableOfData)
in C:\\Lespinoza\\My Source\\XML
Loader\\DataHelper\\SybaseHelper.cs:line 237" string

> > egroups.com... Hi all,

Paul Vero [Sybase]

unread,
Jun 24, 2009, 5:50:50 PM6/24/09
to
Hi Luis,

I think you need to open a tech support case - or could you provide the
whole
repro here so I can take a look at it?

I'm not sure how the source information is prepared.

-Paul

<Luis Espinoza> wrote in message news:4a412560.391...@sybase.com...

Paul Vero [Sybase]

unread,
Jun 24, 2009, 6:17:37 PM6/24/09
to
Hi Luis,

I think you need to open a tech support case - or could you provide the
whole
repro here so I can take a look at it?

I'm not sure how the source information is prepared.

-Paul

<Luis Espinoza> wrote in message news:4a412560.391...@sybase.com...

luisespinoza

unread,
Jun 25, 2009, 3:48:49 PM6/25/09
to
Paul,
how I can open a tech support case?

> Hi Luis,
>
> I think you need to open a tech support case - or could
> you provide the whole
> repro here so I can take a look at it?
>
> I'm not sure how the source information is prepared.
>
> -Paul
>
> <Luis Espinoza> wrote in message
> > news:4a412560.391...@sybase.com... Paul,
> > the error occur when the sentence
> >
> > bulkCopy.WriteToServer(tableOfData);
> >
> > run, no data are sending to server and the table keep
> > empty. No records was inserted and the exception return
> > this information
> >
> > Message
> > "Unable to cast object of type 'System.Int16' to type
> > 'System.String'." string
> >
> > Source
> > "Sybase.AdoNet2.AseClient" string
> >
> > StackTrace "
> > at
> >
> Sybase.Data.AseClient.AseBulkCopy.GenerateInsertCmd(DataTa
> > ble rowFmt)\r\n
> > at
> >
> Sybase.Data.AseClient.AseBulkCopy.PrepareMetaInfo(DataTabl

> > e clientTableFmt)\r\n

Paul Vero [Sybase]

unread,
Jun 26, 2009, 12:05:33 PM6/26/09
to
Hi Luis,

You can call Customer Service at 1-800-879-2273 (1-800-8SYBASE)
They should be able to start you through the process.

-Paul


<Luis Espinoza> wrote in message news:4a43d4a1.336...@sybase.com...

Sebastian Santa Cruz

unread,
Sep 29, 2020, 9:56:00 AM9/29/20
to
Hi, were you able to solve the problem?
0 new messages