public void createTable() { DataSet ds = new DataSet(); using (DataTable dt = new DataTable("students")) { //创建列 DataColumn dtc = new DataColumn("姓名",typeof(string)); dt.Columns.Add(dtc); dtc = new DataColumn("性别",typeof(string)); dt.Columns.Add(dtc); dtc = new DataColumn("电话",typeof(Int32)); dt.Columns.Add(dtc); //添加数据到DataTable DataRow dr = dt.NewRow(); dr["姓名"] = "张三"; dr["性别"] = "男"; dr["电话"] = 54531; dt.Rows.Add(dr); dr = dt.NewRow(); dr["姓名"] = "李四"; dr["性别"] = "男"; dr["电话"] = 5731; dt.Rows.Add(dr); dr = dt.NewRow(); dr["姓名"] = "王五"; dr["电话"] = 5868451; dr["性别"] = "女"; dt.Rows.Add(dr); ds.Tables.Add(dt); } }