Question

How can I edit Dataset's (.xsd file) Query's CommandText in Runtime mode ?

How can give new sql query ?

Was it helpful?

Solution

It is not the Dataset that contains the CommandText, it is the DataAdapter which contains 4 commands :

public sealed class SqlDataAdapter
{
    public SqlCommand DeleteCommand { get; set; }
    public SqlCommand InsertCommand { get; set; }
    public SqlCommand SelectCommand { get; set; }
    public SqlCommand UpdateCommand { get; set; }
}

For example, if you want to change the select sql :

var dataset = new MyDataSet();
var adapter = new MyTableAdapter();
adapter.Adapter.SelectCommand.CommandText = "SELECT * FROM FOO";
adapter.Fill(dataset.MyTable);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top