[Last Call] Learn how to a build a cloud-first strategyRegister 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
  • 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.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

825 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