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

Unable to cast AseCommandBuilder to DbCommandBuilder

34 views
Skip to first unread message

kenn.minear

unread,
Jan 5, 2010, 3:47:00 PM1/5/10
to
I am implementing a factory model with Sybase ASE as one of
the available database backend engines. When I try to cast
the CommandBuilder, I get the following exception:

"Unable to cast object of type
'Sybase.Data.AseClient.AseCommandBuilder' to type
'System.Data.Common.DbCommandBuilder'."

My code is:
DbCommandBuilder builder = null;
builder =
(DbCommandBuilder)Activator.CreateInstance(typeof(Sybase.Data.AseClient.AseCommandBuilder)
, adapter);

I am using Sybase.AdoNet2.AseClient.dll and sybdrvado20.dll

I do not have any problems casting other objects such as a
datareader or a datacommand.

My environment is:
Microsoft Visual Studio 2008 |
Version 9.0.21022.8 RTM |
Microsoft .NET Framework |
Version 3.5 SP1 |
Installed Edition: C# Express |
Microsoft Visual C# 2008 91910-152-0000061-60814 |
Microsoft Visual C# 2008 |
Microsoft Windows Vista Ultimate
Version 6.0.6001 Service Pack 2 Build 6002 |
IIS Version 7.0.6000.16386 |
Express Studio Net 3.5 |

Any suggestions or known issues with the AseADO client would
be helpful.

Regards, Kenn

Paul Vero [Sybase]

unread,
Jan 5, 2010, 5:09:16 PM1/5/10
to
Hi Kenn,

What version of the Provider is this?

-Paul

<kenn.minear> wrote in message news:4b43a543.291...@sybase.com...

Paul Vero [Sybase]

unread,
Jan 5, 2010, 5:11:03 PM1/5/10
to
Also what happens when you do

Sybase.Data.AseClient1.AseCommandBuilder ???

-Paul

<kenn.minear> wrote in message news:4b43a543.291...@sybase.com...

kenn.minear

unread,
Jan 5, 2010, 5:35:27 PM1/5/10
to
Just a side note, I do not have any problems connecting from
either my WinForm application or from my ASP.Net application
by deploying only the two DLL's to the bin libraries. I am
configured using only IPv4 (no IPv6) so I have to use the IP
address in place of the server name.

Regards, Kenn

kenn.minear

unread,
Jan 5, 2010, 5:38:54 PM1/5/10
to
Hi Paul, I'm not quite sure without doing a lot of digging
of the version number, I downloaded everything on
12/18/2009... so I assume it is your latest version.

Regards, Kenn

> Hi Kenn,
>
> What version of the Provider is this?
>
> -Paul
>
> <kenn.minear> wrote in message
> news:4b43a543.291...@sybase.com... >I am
> > implementing a factory model with Sybase ASE as one of
> the available database backend engines. When I try to
> > cast the CommandBuilder, I get the following exception:
> >
> > "Unable to cast object of type
> > 'Sybase.Data.AseClient.AseCommandBuilder' to type
> > 'System.Data.Common.DbCommandBuilder'."
> >
> > My code is:
> > DbCommandBuilder builder = null;
> > builder =
> >
> (DbCommandBuilder)Activator.CreateInstance(typeof(Sybase.D

> > ata.AseClient.AseCommandBuilder) , adapter);

kenn.minear

unread,
Jan 5, 2010, 5:42:13 PM1/5/10
to
Hi Paul,

I'm not sure I quite understand the question, I don't use
the API directly, the objects are cast to System.Data.Common
objects and executed using normal ADO commands, this way the
code doesn't need to know whether they are talking to Sybase
ASE, IBM DB2, PostgreSQL, etc. This is working great, I can
do all my CRUD functions against ASE, query, etc. The only
thing I cannot do is cast the command builder to update a
dataset.

Regards, Kenn

> Also what happens when you do
>
> Sybase.Data.AseClient1.AseCommandBuilder ???
>
> -Paul
>
> <kenn.minear> wrote in message
> news:4b43a543.291...@sybase.com... >I am
> > implementing a factory model with Sybase ASE as one of
> the available database backend engines. When I try to
> > cast the CommandBuilder, I get the following exception:
> >
> > "Unable to cast object of type
> > 'Sybase.Data.AseClient.AseCommandBuilder' to type
> > 'System.Data.Common.DbCommandBuilder'."
> >
> > My code is:
> > DbCommandBuilder builder = null;
> > builder =
> >
> (DbCommandBuilder)Activator.CreateInstance(typeof(Sybase.D

> > ata.AseClient.AseCommandBuilder) , adapter);

kenn.minear

unread,
Jan 5, 2010, 5:44:50 PM1/5/10
to
There was another post at the following link that experience
the same problem, but I don't think they ever resolved it.

http://www.eggheadcafe.com/community/aspnet/10/10029734/error-with-dataadapterup.aspx

Regards, Kenn

> I am implementing a factory model with Sybase ASE as one
> of the available database backend engines. When I try to
> cast the CommandBuilder, I get the following exception:
>
> "Unable to cast object of type
> 'Sybase.Data.AseClient.AseCommandBuilder' to type
> 'System.Data.Common.DbCommandBuilder'."
>
> My code is:
> DbCommandBuilder builder = null;
> builder =
> (DbCommandBuilder)Activator.CreateInstance(typeof(Sybase.D

> ata.AseClient.AseCommandBuilder) , adapter);

kenn.minear

unread,
Jan 5, 2010, 5:57:49 PM1/5/10
to
Hi Paul, The version is 2.155.1000.0

Regards, Kenn

kenn.minear

unread,
Jan 5, 2010, 7:11:25 PM1/5/10
to
While browsing the objects in the ASE ADO class, I noticed
something different about AseCommandBuilder from all of the
other objects.

For example:

AseCommand
+- Base Types
+- Component
+- ICloneable
+- IDbCommand
+- IDisposable

AseCommandBuilder
+- Base Types
+- Component
+- IComponent
+- IDisposable
+- MarshalByRefObject

Shouldn't there be an IDBCommandBuilder under Component?
Every other object has an IDb<Type> under it's component.

I hope this might be a clue why I can't cast the
AseCommandBuilder to DbCommandBuilder.

Regards, Kenn

kenn.minear

unread,
Jan 5, 2010, 7:17:09 PM1/5/10
to
Please disregard, other DB implementations have the same
structure (and they work correctly). Sorry about that.

Regards, Kenn

kenn.minear

unread,
Jan 5, 2010, 8:33:36 PM1/5/10
to
Hi Paul,

I modified my code to check for Sybase as the backend and
used the AseCommandBuilder object directly. It works fine.
I can live with this workaround, but I think you should be
aware that there is some problem with not being able to cast
AseCommandBuilder to DbCommandBuilder.

Regards and thanks for your help, Kenn

> Also what happens when you do
>
> Sybase.Data.AseClient1.AseCommandBuilder ???
>
> -Paul
>
> <kenn.minear> wrote in message
> news:4b43a543.291...@sybase.com... >I am
> > implementing a factory model with Sybase ASE as one of
> the available database backend engines. When I try to
> > cast the CommandBuilder, I get the following exception:
> >
> > "Unable to cast object of type
> > 'Sybase.Data.AseClient.AseCommandBuilder' to type
> > 'System.Data.Common.DbCommandBuilder'."
> >
> > My code is:
> > DbCommandBuilder builder = null;
> > builder =
> >
> (DbCommandBuilder)Activator.CreateInstance(typeof(Sybase.D

> > ata.AseClient.AseCommandBuilder) , adapter);

Paul Vero [Sybase]

unread,
Jan 12, 2010, 1:11:05 PM1/12/10
to
Hi Kenn,

Will you be able to open a Tech Support case with Sybase so this
can be reported to Engineering. I don't know why this shouldn't work.
It might be an issue withthe declaration in the Provider code or maybe some
reason why it
itsn't "inheriting" this capability from teh generic class.

At leastr we could report it and if it's resolvable then at some point you
can code the way you
want.

Thank you.

-Paul

<kenn.minear> wrote in message news:4b43e870.34b...@sybase.com...

0 new messages