Answers for "datatable with sql c#"

4

C# create DataTable

DataTable dt = new DataTable(); 
dt.Clear();
dt.Columns.Add("Name");
dt.Columns.Add("Marks");

DataRow _ravi = dt.NewRow();
_ravi["Name"] = "ravi";
_ravi["Marks"] = "500";
dt.Rows.Add(_ravi);
Posted by: Guest on August-20-2020
1

datatable in c#

String[] arr = new String[] { "a", "b" };
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("other");
            dt.Rows.Add(arr);

            foreach (DataRow r in dt.Rows)
            {
                Console.WriteLine(r["name"].ToString() + " - " + r["other"].ToString());
            }
Posted by: Guest on October-19-2021
-2

how to make a datatable in c#

Datatable NameHere = new DataTable();
NameHere.Rows.Add("Whateveryoudliketoaddintorstringoranything");
Posted by: Guest on May-22-2020

Browse Popular Code Answers by Language