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"] = ...;
thisDataSet.Tables["tb"].Rows.Add(thisRow);
thisAdaper.Update(thisDataSet, "tb");我用 SqlCommand sqltext = thisBuilder.GetInsertCommand();
Response.Write(sqltext.CommandText);打印出来的sql 却是INSERT INTO [House] ([col1],[col2],[col3],[col4][col5],[col6],[col7],[col8][col9],[col10]]) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)
他将表中所有字段都列了出来了 这就造成表中一些 default约束被覆盖了 其实我要构造的SQL 只是
INSERT INTO [House] ([col1],[col2],[col3],[col4]]) VALUES (@p1, @p2, @p3, @p4)这应该怎么做
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"] = ...;
thisDataSet.Tables["tb"].Rows.Add(thisRow);
thisAdaper.Update(thisDataSet, "tb");我用 SqlCommand sqltext = thisBuilder.GetInsertCommand();
Response.Write(sqltext.CommandText);打印出来的sql 却是INSERT INTO [House] ([col1],[col2],[col3],[col4][col5],[col6],[col7],[col8][col9],[col10]]) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)
他将表中所有字段都列了出来了 这就造成表中一些 default约束被覆盖了 其实我要构造的SQL 只是
INSERT INTO [House] ([col1],[col2],[col3],[col4]]) VALUES (@p1, @p2, @p3, @p4)这应该怎么做
SqlDataAdapter thisAdaper = new SqlDataAdapter(StrSQL, DbConn);
DataSet thisDataSet = new DataSet();
thisAdaper.Fill(thisDataSet, "tb");
DataRow thisRow = thisDataSet.Tables["tb"].NewRow(); thisRow["col1"] = textbox.text;
thisRow["col2"] = ...;
thisRow["col3"] = ...;
thisRow["col4"] = ...;
thisDataSet.Tables["tb"].Rows.Add(thisRow);
thisAdaper.Update(thisDataSet, "tb");