Accessing ORACLE with SQL SERVER generated Business Object (Problem)


Author
Message
Ertan Deniz
Ertan Deniz
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Business Object was filled from ORACLE. (Table)

But When I 'm trying to access "id" property getting the error "specified cast is not valid".

Id property (Int32), Datatable.Column.type is System.Decimal. (ORacle table column is NUMBER").

I've run the query through FillDataTable("Select statement") command.

public System.Int32 id

{

get

{

return (System.Int32)this.CurrentRow["id"];

}

set

{

this.CurrentRow["id"] = value;

}

}

Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, let's get to the crux of this topic as this is not going to be a quick post and falls more on the side of consultation.  This can become a very deep and complex topic which is not the intent of the forum.  But here is the bottom line when you are trying to do something like this (which is possible but requires some good foundation laying).

You should always create a base BO which all of your BOs within your application inherit from.  So let's just say BaseBO.  Within this base BO, I am going to overwrite the FillDataTable method.  I may need to override several others as well before all is said and done in order to take the automatic conversion into account.

When writing your application, you will always want to create your queries, etc. towards a specific database (i.e. SQL Server).  Now let's assume that you have the need to implement Oracle.  I will create a shared property within my application to which the BaseBO looks.  If it is set to Oracle, then anytime that the FillDataTable is called, the BaseBO will automatically convert an SqlDbCommand into an OracleDbCommand.  This is the approach that we have used within our medical software and it has worked just fine.

Next, you may need to "scrub" all values through an Accessing event or by overriding or shadowing the CurrentRow property or something along those lines if there are type conversion issues.  But again, this will be done within the BaseBO so that you only have to place this logic in a single location.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ertan Deniz - 17 Years Ago
Dustin Taylor - 17 Years Ago
Ertan Deniz - 17 Years Ago
Greg McGuffey - 17 Years Ago
StrataFrame Team - 17 Years Ago
Ertan Deniz - 17 Years Ago
Ertan Deniz - 17 Years Ago
Ertan Deniz - 17 Years Ago
Dustin Taylor - 17 Years Ago
Ertan Deniz - 17 Years Ago
David Daragon - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Ertan Deniz - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Ertan Deniz - 17 Years Ago
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search