Can i add Table DataTable into DataSet of Class ?


Author
Message
Dong Trien Lam
Dong Trien Lam
StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)StrataFrame User (173 reputation)
Group: Anonymous / Guest
Posts: 57, Visits: 251
When I press F5 error: warning error here: Cannot implicitly convert type 'void' to 'System.Data.DataTable'

public class NewDataSet : DataSet
    {
        public NewDataSet()
            : base()
        {
            DataTable dt = new DataTable("table");
            DataSetName = "NewDataSet";

            dt.Columns.Add("item_desc", typeof(string));
            dt.Columns.Add("Ins", typeof(int));
            dt.Columns.Add("Kg", typeof(int));
            dt.Columns.Add("Qty", typeof(int));
            dt.Columns.Add("Total", typeof(int));
            dt.Columns.Add("Date", typeof(DateTime));

            Tables.AddRange(new DataTable[] { dt });
        }

        public static NewDataSet CreateData(DataTable dta)
        {
            NewDataSet ds = new NewDataSet();
            DataTable dt = ds.Tables.Add(dta); // warning error here: Cannot implicitly convert type 'void' to 'System.Data.DataTable'

            return ds;
        }



        #region Disable Serialization for Tables and Relations
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new DataTableCollection Tables
        {
            get { return base.Tables; }
        }



        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new DataRelationCollection Relations
        {
            get { return base.Relations; }
        }
        #endregion Disable Serialization for Tables and Relations

    }

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search