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.
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

LVL 44

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

741 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