Step 2: Setting up your Project to Use the Data Web Service

Follow these instructions to allow your project to use the web service for data access.

  1. In the Solution Explorer, right-click your Business Object project and select Add Reference... from the shortcut menu. In the Add Reference dialog under the .NET tab, scroll down and select the MM .NET Framework Web Services assembly, then click OK:

  2. In the Solution Explorer, right-click your Windows Forms or Web Forms project and select Add Reference... from the shortcut menu. In the Add Reference dialog under the .NET tab, scroll down and select the MM .NET Framework Web Services assembly again, then click OK:

  3. Now double-click your Windows Forms or Web Forms Factory.cs or Factory.vb file and add code to override the CreateDataAccessSql() method (if you are using Oracle, override the CreateDataAccessOracle() method, and so on). Also add the using or Imports statements shown at the top of each code sample. Notice this code is checking the mmAppBase.DefaultDataAccessMode property to determine whether to run the default base code that instantiates a regular data access class or a web service data access class. In the constructor of the Web Service proxy class, you can pass the URL of the web service:

    For example, in C#:

    using OakLeaf.MM.Main;
    using OakLeaf.MM.Main.Data;
    
    public class Factory : mmFactoryDesktop
    {
    	public override OakLeaf.MM.Main.Data.mmDataAccessSql CreateDataAccessSql()
    	{
    		if (mmAppBase.DefaultDataAccessMode == mmDataAccessMode.Local)
    		{
    			return base.CreateDataAccessSql();
    		}
    		else
    		{
    			return new mmDataAccessWebServiceSql("http://localhost/MM%20.NET%202026%20Data%20Access%20Web%20Service/DataWebService.asmx");
    		}
    	}
    }

    And in VB .NET:

    Imports OakLeaf.MM.Main
    Imports OakLeaf.MM.Main.Data
    
    Public Class Factory
       Inherits mmFactoryDesktop
       
       Public Overrides Function CreateDataAccessSql() As OakLeaf.MM.Main.Data.mmDataAccessSql
          If mmAppBase.DefaultDataAccessMode = mmDataAccessMode.Local Then
             Return MyBase.CreateDataAccessSql()
          Else
             Return New mmDataAccessWebServiceSql("http://localhost/MM%20.NET%202026%20Data%20Access%20Web%20Service/DataWebService.asmx")
          End If
       End Function
    
    End Class

    Rather than passing the hard-coded Web Service URL you may want to store the URL in a database or local config file so you can change the URl without recompiling your application. Another overload of the constructor also allows you to pass an System.Net.ICredentials object that contains credentials to be passed to the web service.


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/10/26
Comment or report problem with topic