troubleshooting Question

Can i make the No of fields in a GetObject Method any no of items

Avatar of Olukayode Oluwole
Olukayode OluwoleFlag for Canada asked on
.NET ProgrammingC#* StoredProcedure
4 Comments1 Solution16 ViewsLast Modified:
I have in my c# application a need to write into a postgresql database

I use a simple GetObject method shown below

[code]private void WriteRecord()
            var p = GetObject(LocationIDValue.Text, LocDescriptionValue.Text, LoginDetails.staticcompany, Convert.ToInt32(idValue.Text), LoginDetails.staticinsertupdatedeletetag);
            NewDataAccess.WriteData("public.splocationcode_updateinsert", p);

It takes fields value from the screen passes them to GetObject method to define
parameters before  using these to write in to my postgresql database

The GetObject Method is shown below

       []public static object GetObject(string parameter01, string parameter02, string parameter03, int parameter04, string parameter05)
            return new
                    locationidx = parameter01,
                    locdescriptionx = parameter02,
                    companycodex = parameter03,
                    idx = parameter04,
                    dowhatx = parameter05


The applications works fine for this Table with 5  fields

The problem i now have is if i have to address  writing to another table with fields more or less than 5 fields.
Do I have to provide a  GetObject method with the no of parameters equal to the no of fields in that Table.. If Yes will i have to do this for every table in my application ??

Is there a way to make the no of items in the GetObject method have any no of fields.

I was thinking of checking the GetObject Method into a library and then pass the no of fields as  string  and the parameters   as a Datatable

I just dont know if my thinking  is right or if there is another way to achieve the same goal of using the GetObject method to address  2 tables with different no of fields

I will be grateful for any suggestion.


Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros