473,467 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is it possible to use inheritance here or some other construction to make the code less

Hello!!

Below I have some methods that first setup a select string then read the
dataset into a ArrayList.
I have used the Data Adaper ConfigurationWizard for these adapter that I use
here.

I just wonder if it's possible to use inheritance and polymorfism or some
other construction here to minimize that code.

private void loadComposition()
{
DataSet dSMspComposition = new DataSet();
OleDbDataAdapter mspCompositionAdapter=
MeltPracStorage.instance.mspCompositionAdapter;
mspCompositionAdapter.SelectCommand.CommandText = "select distinct
comp_name from msp_comp";
mspCompositionAdapter.Fill(dSMspComposition);
foreach (DataRow row in dSMspComposition.Tables[0].Rows)
compositionList.Add(row["COMP_NAME"]);
}

private void loadCorrectionsAndAlloys()
{
DataSet dSMspCorrections = new DataSet();
OleDbDataAdapter mspCorrectionsAdapter =
MeltPracStorage.instance.mspCorrectionsAdapter;
mspCorrectionsAdapter.SelectCommand.CommandText = "select distinct
corr_name from msp_corr";
mspCorrectionsAdapter.Fill(dSMspCorrections);
foreach (DataRow row in dSMspCorrections.Tables[0].Rows)
correctionsList.Add(row["CORR_NAME"]);
}

private void loadDesulph()
{
DataSet dSMspDesulph = new DataSet();
OleDbDataAdapter mspDesulphAdapter =
MeltPracStorage.instance.mspDesulphAdapter;
mspDesulphAdapter.SelectCommand.CommandText = "select distinct des_name
from msp_desulph";
mspDesulphAdapter.Fill(dSMspDesulph);
foreach (DataRow row in dSMspDesulph.Tables[0].Rows)
desulphList.Add(row["DES_NAME"]);
}

private void loadMetallurgical()
{
DataSet dSMspMetallurgical = new DataSet();
OleDbDataAdapter mspMetallurgicalAdapter =
MeltPracStorage.instance.mspMetParAdapter;
mspMetallurgicalAdapter.SelectCommand.CommandText = "select distinct
metpar_name from msp_metpar";
mspMetallurgicalAdapter.Fill(dSMspMetallurgical);
foreach (DataRow row in dSMspMetallurgical.Tables[0].Rows)
metallurgicalList.Add(row["METPAR_NAME"]);
}

private void loadTimes()
{
DataSet dSMspTimes = new DataSet();
OleDbDataAdapter mspTimesAdapter =
MeltPracStorage.instance.mspTimeParAdapter;
mspTimesAdapter.SelectCommand.CommandText = "select distinct
timepar_name from msp_timepar";
mspTimesAdapter.Fill(dSMspTimes);
foreach (DataRow row in dSMspTimes.Tables[0].Rows)
timesList.Add(row["TIMEPAR_NAME"]);
}

private void loadMisc()
{
DataSet dSMspMisc = new DataSet();
OleDbDataAdapter mspMiscAdapter =
MeltPracStorage.instance.mspMiscParAdapter;
mspMiscAdapter.SelectCommand.CommandText = "select distinct miscpar_name
from msp_miscpar";
mspMiscAdapter.Fill(dSMspMisc);
foreach (DataRow row in dSMspMisc.Tables[0].Rows)
miscList.Add(row["MISCPAR_NAME"]);
}

private void loadCovLadleList()
{
DataSet dSMspCovLadle = new DataSet();
OleDbDataAdapter mspCovLadleAdapter =
MeltPracStorage.instance.mspCovLadleParAdapter;
mspCovLadleAdapter.SelectCommand.CommandText = "select distinct
covladle_name from msp_covladle";
mspCovLadleAdapter.Fill(dSMspCovLadle);
foreach (DataRow row in dSMspCovLadle.Tables[0].Rows)
covLadleList.Add(row["COVLADLE_NAME"]);
}

//Tony
Apr 7 '06 #1
1 1176
How about just extracting the common lines and

DataSet dSMspCovLadle = PopulateDataSet("select distinct
covladle_name from msp_covladle",
MeltPracStorage.instance.mspCovLadleParAdapter);
<plus six more lines like this>

private DataSet PopulateDataSet(string commandText, OleDbDataAdapter
odda, List list)
{
DataSet ds = new DataSet();
odda.SelectCommand.CommandText = commandText;
odda.Fill(dSMspCovLadle);
foreach (DataRow row in ds.Tables[0].Rows)
list.Add(row["COVLADLE_NAME"]);
return ds;
}

Apr 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
12
by: Steve Jorgensen | last post by:
The classing Visual Basic and VBA support for polymorphism, let's face it, is a bit on the weak side, and built-in support for inheritance is non-existent. This little essay is about some patterns...
8
by: Mike - EMAIL IGNORED | last post by:
I have a class that may or may not be inherited. Its constructor calls a function that should be called only if the class is not inherited. Is there a way to tell, other than simply passing a...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: burningodzilla | last post by:
Hi all - I'm preparing to dive in to more complex application development using javascript, and among other things, I'm having a hard time wrapping my head around an issues regarding "inheritance"...
49
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current...
21
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 {...
40
by: RvGrah | last post by:
I've been writing in C# for about 4 years now, coming from VB.net and VB6 before that, in which I know I'm not alone. I found learning C#, at least to the extent that I use it in developing...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.