C# OO concept and SQL Server Table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Huang

    #1

    C# OO concept and SQL Server Table

    Hi,

    My project is .Net 1.1 C# Windows Form project, and the database server is
    SQL Server 2000.
    In one of the database's datatable MyTable, the Primary Key is a Join Key
    [Name, Number].
    Now in my C# Windows form MyForm, it is designed mainly for manipulating the
    datatable MyTable.
    I am thinking if we apply the OO concept, do we need to have public function
    like:

    public string[,] GetMyTable(stri ng aName,string aNumber)

    Since I am thinking the [Name, Number] will indicate a unique row in the
    MyTable in SQL Server.
    Also, do I need to build a contsructor for pass value [Name, Number] for
    other forms?
    Thanks for help.


    Jason



  • Jonathan Woods

    #2
    Re: C# OO concept and SQL Server Table

    First of all, why don't u use single primary key instead of using Join
    Key (according term u used). U can create it manually or
    uniqueidentifie r with default value - newid()

    Secondly, u can use DataSet or DataTable object when u need pass data
    to other forms by overloading constructor or using property.

    Hope that help u

    Comment

    • Jay R. Wren

      #3
      Re: C# OO concept and SQL Server Table

      Jason Huang wrote:[color=blue]
      > Hi,
      >
      > My project is .Net 1.1 C# Windows Form project, and the database server is
      > SQL Server 2000.
      > In one of the database's datatable MyTable, the Primary Key is a Join Key
      > [Name, Number].
      > Now in my C# Windows form MyForm, it is designed mainly for manipulating the
      > datatable MyTable.
      > I am thinking if we apply the OO concept, do we need to have public function
      > like:
      >
      > public string[,] GetMyTable(stri ng aName,string aNumber)
      >
      > Since I am thinking the [Name, Number] will indicate a unique row in the
      > MyTable in SQL Server.
      > Also, do I need to build a contsructor for pass value [Name, Number] for
      > other forms?
      > Thanks for help.
      >[/color]

      If you REALLY want to practice good OO, you would use some kind of Data
      Access Object pattern. There is was a good couple of articles posted to
      code project about this recently.




      It may seem overly complicated at first, but with a reasonably small
      amount of code, you can have a true OO model which happens to have a
      database underneath.
      --
      Jay R. Wren

      Comment

      Working...