比如我有一张表
有五个字段 col1 col2 col3 col4 col5
col5上面有一个default约束 然后我需要 在前面四个字段中插入数据 String StrSQL = "Select * From tb"
SqlDataAdapter thisAdaper = new SqlDataAdapter(StrSQL, DbConn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdaper);
DataSet thisDataSet = new DataSet();
thisAdaper.Fill(thisDataSet, "tb");
DataRow thisRow = thisDataSet.Tables["tb"].NewRow(); thisRow["col1"] = ...;
thisRow["col2"] = ...;
thisRow["col3"] = ...;
thisRow["col4"] = ...; thisAdaper.Update(thisDataSet, "tb");这样写以后 tb表中 col5 这个字段 里的default约束被覆盖掉了,变成了NULL我又不想 select col1,col2,col3.... from tb 这样把字段指定出来 因为表里面有 几十个字段 !!!!有什么办法 解决一下? 困扰我好久了! 也不要用 insert语句 那样难以维护..
有五个字段 col1 col2 col3 col4 col5
col5上面有一个default约束 然后我需要 在前面四个字段中插入数据 String StrSQL = "Select * From tb"
SqlDataAdapter thisAdaper = new SqlDataAdapter(StrSQL, DbConn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdaper);
DataSet thisDataSet = new DataSet();
thisAdaper.Fill(thisDataSet, "tb");
DataRow thisRow = thisDataSet.Tables["tb"].NewRow(); thisRow["col1"] = ...;
thisRow["col2"] = ...;
thisRow["col3"] = ...;
thisRow["col4"] = ...; thisAdaper.Update(thisDataSet, "tb");这样写以后 tb表中 col5 这个字段 里的default约束被覆盖掉了,变成了NULL我又不想 select col1,col2,col3.... from tb 这样把字段指定出来 因为表里面有 几十个字段 !!!!有什么办法 解决一下? 困扰我好久了! 也不要用 insert语句 那样难以维护..
DataRow thisRow = thisDataSet.Tables["tb"].NewRow(); thisRow["col1"] = ...;
thisRow["col2"] = ...;
thisRow["col3"] = ...;
thisRow["col4"] = ...;thisDataSet.Tables["tb"].Rows.Add(thisRow); thisAdaper.Update(thisDataSet, "tb");
是不是因为缺少这句话呢?