public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
using (var connection = factory.CreateConnection())
{
using (DbCommand command = factory.CreateCommand())
{
connection.ConnectionString = connectionString;
command.Connection = connection;
command.CommandType = commandType;
command.CommandText = commandText;
command.Parameters.AddRange(commandParameters);
connection.Open();
DataSet ds = new DataSet();
DataTable table = new DataTable();
table.Load(command.ExecuteReader());
ds.Tables.Add(table);
connection.Close();
return ds;
}
}
}
But it is working only once. When I run my code, Sql tab shows only information run through it for the first time, that is only one SP is shown all the time.
And if I perform some other action also like going to new tab in my web page again it shows the same SP information.
Am I missing anything here.