如何在运行时模式下修改Dataset's
(.xsd file
)查询CommandText
?
如何提供新的SQL查询?
答案 0 :(得分:-1)
不是包含CommandText的数据集,而是包含4个命令的DataAdapter:
public sealed class SqlDataAdapter
{
public SqlCommand DeleteCommand { get; set; }
public SqlCommand InsertCommand { get; set; }
public SqlCommand SelectCommand { get; set; }
public SqlCommand UpdateCommand { get; set; }
}
例如,如果要更改select sql:
var dataset = new MyDataSet();
var adapter = new MyTableAdapter();
adapter.Adapter.SelectCommand.CommandText = "SELECT * FROM FOO";
adapter.Fill(dataset.MyTable);