How to provide Readonly remote to Dbase (dbf) files using CSLA

How to provide Readonly remote to Dbase (dbf) files using CSLA

Old forum URL: forums.lhotka.net/forums/t/5155.aspx


cash_pat posted on Friday, July 25, 2008

 How to provide Readonly remote access to Dbase (dbf) files using CSLA. I am confused over:

a) I tried a test run by addding an OleDB connection string to my app.config file. Looks like CSLA defaults to Sql Server !
b) Is it possible to use CSLA for accessing dbf files.
c) If possible then what portions of CSLA do I have to change to enable the access.
d) Any sample posts that could point in the right direction. I tried searching for Oledb but the search results were not very informative
e) I have all the CSLA books. which ones would send me in the right direction.

f) Can i get all the features of CSLA while accessing dbf files

any ideas


regards

cash pat

triplea replied on Friday, July 25, 2008

Hi

a) If you did your change and test on PTracker then this wouldnt work. In that example SQL Connections/Commands are used so of course changing the App.config would make no difference. I think thats what you mean by saying it defaults to SQL server, if not please correct me.

b) Sure, any datasource really.

c) The dataportal_XYZ methods (Fetch/Insert/Update/Delete and maybe Create). Using ADO or any other DA way you would normally use.

f) Yes

Hope this helps

 

Q Johnson replied on Friday, July 25, 2008

Pat,

It seems likely you are confusing CSLA framework code with PTracker  application sample code.  PTracker is an example of an application using the CSLA libraries with Business Object code that uses Sql Server for data persistance.  But you can use any technique you want (including writing text files, XML, the registry, Oracle, Access, dBase, FoxPro, ad nauseum) to do your CRUD methods in the DataPortal_XYZ methods of your individual Business Objects.  Just be sure and reference the correct dot NET System.Data.<your choice here>  libraries in your Business Object code.


>>a) I tried a test run by addding an OleDB connection string to my app.config file. Looks like CSLA defaults to Sql Server ! <<
CSLA doesn't default to ANY database engine usage. 

>>b) Is it possible to use CSLA for accessing dbf files.<<
Yes, certainly it is.

>>c) If possible then what portions of CSLA do I have to change to enable the access.<<
You needn't (and shouldn't) change any CSLA code.

>>d) Any sample posts that could point in the right direction. I tried searching for Oledb but the search results were not very informative<<
Just look for code samples that use Microsoft Access.  The connection string for dBase will be different , of course, but the use of the OleDb objects will be the same for dBase.  You'll find yourself using code like this:

  Dim cn As New OleDbConnection(<your value here>))
  Dim cmd As New OleDbCommand
  Dim tr As OleDbTransaction

The <your value here> portion will contain your technique for retrieving your database's connection string.  Best technique is to use some function to return it rather than using a literal string value, of course.  In Expert VB 2005 Business Objects (CSLA 2), Rocky uses a helper class in PTracker, for example (see page 427 and the discussion of Database.PTrackerConnection).  In CSLA 1, Rocky provided a Protected DB() method of BusinessBase that offered the same functionality.  Both of these are just wrappers that will extract the Connection String stored in your app's config file.

>>e) I have all the CSLA books. which ones would send me in the right direction.<<
They all should

>>f) Can i get all the features of CSLA while accessing dbf files<<
Yes.

Again, the trick is to use the OleDbConnection, OleDbCommand, and OleDbTransaction objects rather than SqlConnection, SqlCommand, and SqlTransaction (which are unique to SqlServer).  And it will be easiest to use these if you provide references to the System.Data.OleDb library at the project level.

Hope this helps.

Copyright (c) Marimer LLC