[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


generics problem

Posted on 2013-01-09
Medium Priority
Last Modified: 2013-01-09
I am trying to fill a generic list the intellisence tells me everything is what it is asking for but it keeps giving me an error
System.Collections.Generic.List<PlmData.POLineData>.List(int)' has some invalid arguments
                int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                List<PlmData.POLineData> dd = new List<PlmData.POLineData>(p.GetPODetails(polinekey));               try
                    qcd.custname = dd[0].CustName;
                    qcd.factory = dd[0].Factory;

Open in new window

any help would be greatly appreciated
Question by:r3nder
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38758917
What type of object does "p.GetPODetails" return?

Author Comment

ID: 38758997
       public PODetailsData GetPODetails(int poLineKey)
            PODetailsData result = null;

            string sql = @"   select cast(cast(POnumber as int) as varchar)  as ponumber,Custid,poluid";
            sql += @" ,upper(Custid) as custid,upper(custname) as custname   ";
            sql += @",upper(vpo.custpo) as custpo,upper(Itemid) as itemid,Upper(description) as description ";
            sql += @",PODate, vpo.leadtime ,promisedate   ";
            sql += @",Upper(factory) as factory,companyid";
            sql += @",vpo.polinekey  ,Upper(vpo.Vendid) as vendid ";
            sql += @",vpo.pokey,purchamt ,fobid,NULLIF (QCBegDate, '01/01/1900') AS QCBegDate,NULLIF (QCEndDate, '01/01/1900') as QCEndDate ";
            sql += @",isNull(CuttingQuantity,0) as cuttingQty ";
            sql += @",	isNull(PaintedQuantity,0) PaintedQty ,	isnull(AssembledQuantity,0) assembledQty ";
            sql += @",	isnull(PackedOutQuantity,0) packedQty ";
            sql += @",	lvbl.saildate,lvbl.etaport eta,lvbl.etdport etd,isnull(lvbl.vbexists,0) as vbexists,isnull(pld.POLStatusID,0) POLStatusID  ";
            sql += @",	lvbl.cargoreturndt  ";
            sql += @"from vPOAllDetailswithCust vpo          ";
            sql += @" left outer join POLDetails pld on pld.polinekey = vpo.polinekey ";
            sql += @" left join vLatestVesselBooking lvbl on lvbl.polinekey = vpo.POLineKey";

            sql += @" Where vpo.polinekey=" + poLineKey;

            using (SqlConnection conn = new SqlConnection(DBConnectionString.Get(Database.TaskManager)))
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.CommandType = CommandType.Text;


                SqlDataReaderHelper reader = new SqlDataReaderHelper(cmd.ExecuteReader());
                if (reader != null && reader.IsValid)
                    while (reader.Read())
                        result = new PODetailsData()
                            PONumber = reader.GetString("PONumber", ""),
                            //AcctMgrID = reader.GetString("AcctMgrID", ""),
                            CustID = reader.GetString("CustID", ""),
                            PolUID = reader.GetInt("PolUID", 0),
                            CustName = reader.GetString("CustName", ""),
                            CustPO = reader.GetString("CustPO", ""),
                            ItemID = reader.GetString("ItemID", ""),
                            Description = reader.GetString("Description", ""),
                            PODate = reader.GetNullableDateTime("PODate"),
                            LeadTime = reader.GetInt("LeadTime", 0),
                            PromiseDate = reader.GetNullableDateTime("PromiseDate"),
                            //ProdBoxArtDT = reader.GetNullableDateTime("ProdBoxArtDT"),
                            //ProdMcDT = reader.GetNullableDateTime("ProdMcDT"),
                            //ProdCustTestingDT = reader.GetNullableDateTime("ProdCustTestingDT"),
                            //ProdMTSInspectDT = reader.GetNullableDateTime("ProdMTSInspectDT"),
                            Factory = reader.GetString("Factory", ""),
                            CompanyID = reader.GetString("CompanyID", ""),
                            POLineKey = reader.GetInt("POLineKey", 0),
                            //IdeaUID = reader.GetInt("IdeaUID", 0),
                            VendID = reader.GetString("VendID", ""),
                            POKey = reader.GetInt("POKey", 0),
                            PurchAmt = reader.GetDecimal("PurchAmt", 0),
                            FobID = reader.GetString("FobID", ""),
                            QCBegDate = reader.GetNullableDateTime("QCBegDate"),
                            QCEndDate = reader.GetNullableDateTime("QCEndDate"),
                            CuttingQuantity = reader.GetInt("CuttingQty", 0),
                            PaintedQuantity = reader.GetInt("PaintedQty", 0),
                            AssembledQuantity = reader.GetInt("AssembledQty", 0),
                            PackedOutQuantity = reader.GetInt("PackedQty", 0),
                            SailDate = reader.GetNullableDateTime("SailDate"),
                            EtaPort = reader.GetNullableDateTime("Eta"),
                            EtdPort = reader.GetNullableDateTime("Etd"),
                            VBExists = reader.GetBool("VBExists", false),
                            POLStatusID = reader.GetInt("POLStatusID", 0),
                            cargoreturndt = reader.GetNullableDateTime("cargoreturndt")


            return result;

Open in new window

LVL 75

Accepted Solution

käµfm³d   👽 earned 1500 total points
ID: 38759079
Youre attempting to stick a PODetailsData object into a list that is expecting PlmData.POLineData objects. Also, the overload you are looking for takes in an array or another list of objects, not a single object, which is what your function returns.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 45

Expert Comment

ID: 38759233
I know you aren't going to be interested but here goes anyway.  I'd suggest you have a look about collections in the help files - specifically about how to use them.  (Obviously you didn't understand the advice given to you in your previous question after all).

Author Comment

ID: 38759296
Got it
               int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                PlmData.PODetailsData dd = new PlmData.PODetailsData();
                dd = p.GetPODetails(polinekey);

Author Closing Comment

ID: 38760348
POBindingSource.DataSource = DataContext;
DataContext = _detailsData;
int polinekey = Convert.ToInt32(e.Row.Cells["polinekey"].Value);
                PlmData.PO p = new PlmData.PO();
                PlmData.PODetailsData dd = new PlmData.PODetailsData();
                dd = p.GetPODetails(DataContext,polinekey);

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question