BrainDump
  Home arrow BrainDump arrow Page 5 - Developing an Object Oriented Business Com...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Developing an Object Oriented Business Component Using WCF and Visual Studio 2008
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2007-10-31

    Table of Contents:
  • Developing an Object Oriented Business Component Using WCF and Visual Studio 2008
  • Understanding the WCF Business Component
  • Understanding the WCF Business Component: Source Code for Entity classes
  • Understanding the WCF Business Component: Source Code for Business Logic
  • Understanding the WCF Business Component: Source Code for “DBHelper”

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Developing an Object Oriented Business Component Using WCF and Visual Studio 2008 - Understanding the WCF Business Component: Source Code for “DBHelper”


    (Page 5 of 5 )

    I kept this utility class (“DBHelper”) very simple. It can be enhanced by implementing features like stored procedure access, support for transactions and so on.

    In fact, I suggest you go to Microsoft Enterprise Library and use the Data Access Application block as part of the “DBHelper” façade. If you are new to Microsoft Enterprise Library (or Data Access Application block), you can find my excellent series on the subject at:

    http://www.aspfree.com/c/a/ASP.NET/Developing-ASPNET-20-Applications-with-
    the-Microsoft-Data-Access-Application-Block/

    http://www.aspfree.com/c/a/ASP.NET/Interacting-with-Databases-Using-ASPNET-
    20-with-the-Microsoft-Data-Access-Application-Block/

    http://www.aspfree.com/c/a/ASP.NET/Working-with-Stored-Procedures-using-
    ASPNET-20-with-Microsoft-Data-Access-Application-Block/

    http://www.aspfree.com/c/a/ASP.NET/More-about-Stored-Procedures-using-
    ASPNET-20-with-the-Microsoft-Data-Access-Application-Block/

    The following is the code used for simple data access:


    Imports System.Data

    Imports System.Data.SqlClient


    Public Class DBHelper


      Private Shared Function getConnectionString() As String

      Return My.Settings.cnNorthwind

    End Function


    Public Shared Sub SQLExecute(ByVal strSQL As String)

      Dim Conn As New SqlConnection(getConnectionString)

      Dim cmd As New SqlCommand(strSQL, Conn)

    With cmd

      .Connection.Open()

      .ExecuteNonQuery()

      .Connection.Close()

      .Dispose()

    End With

    End Sub


    Public Shared Function getRow(ByVal strSELECT As String) As DataRow

      Dim da As New SqlDataAdapter(strSELECT, getConnectionString)

      Dim dt As New DataTable

       da.Fill(dt)

       da.Dispose()

    If dt.Rows.Count = 0 Then Return Nothing Else Return dt.Rows(0) 'return only first row

    End Function


    Public Shared Function getDataTable(ByVal strSELECT As String) As DataTable

      Dim Conn As New SqlConnection(getConnectionString)

      Dim da As New SqlDataAdapter(strSELECT, Conn)

      Dim dt As New DataTable

       da.Fill(dt)

       da.Dispose()

    Return dt


    End Function


    Public Shared Function getRowValue(ByVal strSELECT As String) As String

      Dim Conn As New SqlConnection(getConnectionString)

      Dim cmd As New SqlCommand(strSELECT, Conn)

      Dim value As String = ""

    With cmd

      .Connection.Open()

    value = .ExecuteScalar() & "" 'concatenating an empty string..to eliminate null or nothing

      .Connection.Close()

      .Dispose()

    End With

      Return value

    End Function


    End Class

    Hosting, managing and accessing (or consuming) the WCF Service are very similar to my previous articles and I suggest you refer to those.

    I hope you enjoyed the article and any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hai,This is my next contribution following a series on WCF programming using...
     

    BRAINDUMP ARTICLES

    - Internet Explorer 8 Review
    - Nilpo`s Top Windows Add-Ons
    - Beginning Silverlight 2.0 Development using ...
    - Fixing Vista`s Troubles
    - Preparing Windows Images for Mass Deployment
    - The Trouble With Vista
    - Slipstreamed and Unattended Windows Installa...
    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT