C# OO concept and SQL Server Table

J

Jason Huang

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(string 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
 
J

Jonathan Woods

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
uniqueidentifier 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
 
J

Jay R. Wren

Jason said:
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(string 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.

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.

http://www.codeproject.com/dotnet/ADONETOOP.asp
http://www.codeproject.com/dotnet/AdoNetForOopPart2.asp

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top