StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Map BO to MS Access viewExpand / Collapse
Author
Message
Posted 03/17/2008 9:04:03 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/02/2008 2:23:16 AM
Posts: 12, Visits: 45
Can I mapp a BO to a MS Access view?

I have the BO, the view in the mdb, but if I call the BO Mapper tool, only tables are displayed.

Is it possible?

Thanks,

Alex B.

Post #14945
Posted 03/17/2008 9:06:57 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:09:13 PM
Posts: 536, Visits: 2,211
Hi Alex,

I don't know if you can use MS Access views, but maybe you don't really need the view since you can create as many BO with all the filtering and parameters you want to.

Remember that the BO is basically a container for your data and you have to create the SQL statement to bring the data to work with.

 
Post #14946
Posted 03/17/2008 9:57:01 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/02/2008 2:23:16 AM
Posts: 12, Visits: 45
Thanks for replay but I'm not sure how to do this.

I want to populate the BO only for read purpouse, and the view I have in access is a union from 2 tables with some calculated fields (it's not only a talbe with a where filter).

I think it would be more simple to map the view directly to a BO and use this BO to populate my controls (it's a tree list).

Thanks,

Alex B.

Post #14950
Posted 03/17/2008 10:14:31 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:09:13 PM
Posts: 536, Visits: 2,211
Hi Alex,

Take a look at the following post, it may give you an idea of how to JOIN another table in the BO and then create some Custom Field Properties in your BO.

http://forum.strataframe.net/Topic14580-6-1.aspx?Highlight=join

Of course this is in case you will not be able to use your Access view directly in your BO which would be the easiest way for you.

 
Post #14951
Posted 03/17/2008 10:47:23 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
Alex,

We actually use OLEDB to talk to Access and call the GetSchema to return the views...apparently the Access OLEDB provider doesn't return views as a table.  I can add this to a list to look at before the next update, but Edhy is correct in that you could create a query that does this form you.

Access has full ANSI 92 SQL support which means that you can use JOINs, etc, which is all that a view is doing for you anyway...especially as it relates to read-only data.  Here is one post that I have recently talked about how to create an INNER JOIN: http://forum.strataframe.net/FindPost14603.aspx . (It is the same thread that Edhy mentioned).

Post #14953
Posted 03/17/2008 11:46:44 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/02/2008 2:23:16 AM
Posts: 12, Visits: 45
Thanks for your replays. I will try your suggestion but I need a little more help.

I have read the link, but don't understand where to put the query in my BO:

SELECT Staff.*, SchoolTitles.TitleName FROM Staff INNER JOIN SchoolTitles ON Staff.ForeignKey = SchoolTitles.PrimaryKey

Can I retrieve in my fill method more columns than the columns I mapped in the BO mapper?

Can I create a BO with all fields as custom properties? (because my BO don't maps directly to a table, and I can't use the BO mapper tool)

Thanks and excuse for my ignorance

Alex B.

Post #14964
Posted 03/17/2008 12:07:47 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:09:13 PM
Posts: 536, Visits: 2,211
Alex Bibiano González (03/17/2008)
Thanks for your replays. I will try your suggestion but I need a little more help.

I have read the link, but don't understand where to put the query in my BO:

SELECT Staff.*, SchoolTitles.TitleName FROM Staff INNER JOIN SchoolTitles ON Staff.ForeignKey = SchoolTitles.PrimaryKey

Can I retrieve in my fill method more columns than the columns I mapped in the BO mapper?

Can I create a BO with all fields as custom properties? (because my BO don't maps directly to a table, and I can't use the BO mapper tool)

Thanks and excuse for my ignorance

Alex B.

Hi Alex,

No problem, so here we go.....

  1. In the Solution Explorer, right click your BO file and select View Code
  2. Open the Region "Data Retrieval Methods" and create a method here which you will call from anywhere in your form, so let's named it something like GetStaffView and the code should be something like this in VB:

Public Sub GetStaffView()

     Me.FillDataTable("SELECT Staff.*, SchoolTitles.TitleName FROM Staff INNER JOIN SchoolTitles ON Staff.ForeignKey = SchoolTitles.PrimaryKey")

End Sub

You will then call the Me.GetStaffView method from your form's New or Load event or from any other place you want the BO to be populated.

I believe you will also need to create a Custom Field Property to manage the SchoolTitles.TitleName, but I am not sure, so if that is the case let me know to give you some code to do that, or look at the help for the Custom Field Property topic, so you can add it in the same BO file.

 
Post #14965
Posted 03/17/2008 1:28:30 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
Yup. Edhy is right on the money.  You will just create a method within your BO that executes that query for you.
Post #14972
Posted 03/18/2008 4:27:49 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/02/2008 2:23:16 AM
Posts: 12, Visits: 45
Thanks,

I already knew how to code the fill method. My question was if I could fill a datatable with more columns than properties mapped in the BO mapper.

I have already solved my problem changing my DB backend to SQL Server . This project is for me my first test project with Strataframe (I have developed before with Powerbuilder, C# + NHibernate or Datasets) and I'm testing the same project with Oracle, SqlServer an Access.

Thanks a lot for our answers. I think this help forum is great and our support fast and good.

Alex B.

Post #14981