现有代码如下:
//创建学生信息表
DataSet ds = new DataSet();
DataTable dt = new DataTable("StudentInfo");
DataColumn col = new DataColumn("Stud_Number",typeof(int));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = 1;
col.AutoIncrementStep = 1;

dt.Columns.Add(col);col = new DataColumn("Stud_Name",typeof(string));
col.AllowDBNull = false;
col.MaxLength = 10;dt.Columns.Add(col);col = new DataColumn("Stud_Sex",typeof(string));
col.AllowDBNull = false;
col.MaxLength = 2;
col.DefaultValue = "男";dt.Columns.Add(col);col = new DataColumn("Stud_Age",typeof(int));
col.AllowDBNull = true;

dt.Columns.Add(col);
dt.PrimaryKey = new DataColumn[]{dt.Columns["Stud_Number"]};ds.Tables.Add(dt);我如何把上面自己编写的表格更新到数据库中去,也就是说,如何在数据库中生成上面编写的表格。
急啊!100分。请教!

解决方案 »

  1.   

    你是要把表格代码存进去,而不是表格里的数据吗?
    如果要存整个表的话,你可以用把表格加到DATASET.用DATASET生成XML文件.要不,你就只能通过获得HTML代码.
      

  2.   

    System.Data.SqlClient.SqlDataAdapter da=new SqlDataAdapter();
    da.UpdateCommand =CreateUpdateCommand();//自己写的
    da.InsertCommand =CreateInsertCommand();();//自己写的
    da.DeleteCommand =CreateDeleteCommand();();//自己写的
    da.Update(myDataTable);//更新,这样做就是效率不高的,哈哈
      

  3.   

    你这个有包括到建表的吧。如果是包括连建立数据库的话。可以参考http://community.csdn.net/Expert/topic/4016/4016964.xml?temp=.8720056
      

  4.   

    看来只能写入到xml中,然后再导入到数据库中了