Home > Backend Development > C#.Net Tutorial > C# DataTable Usage Summary

C# DataTable Usage Summary

黄舟
Release: 2017-02-20 11:04:55
Original
1800 people have browsed it

1. Create a new table

 private DataTable vsDt =new DataTable();
Copy after login

2. Clear the contents of the table (the columns in the table are still there)

vsDt.Clear();
Copy after login

3. Clear the columns of the table

vsDt.Columns.Clear();
Copy after login

4. Add columns to the table

vsDt.Columns.Add("BH", typeof(string));
vsDt.Columns.Add("RQ", typeof(string));
Copy after login

5. Add empty rows to the table

 DataRow vsDr = vsDt.NewRow();
Copy after login

If you have gone before adding a blank row N columns have been added to the table, so the newly added empty rows will also have these columns.
6. Add rows to the table

vsDt.Rows.Add(vsDr);
Copy after login

The above is the summary of C# DataTable usage. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template