SqlClient GetData Method (SqlCommand)Nemiro.Data.dll
Executes the specified SqlCommand and returns DataSet.

Namespace: Nemiro.Data.Sql
Assembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
Syntax

public DataSet GetData(
	SqlCommand cmd
)

Parameters

cmd
Type: System.Data.SqlClient SqlCommand
Instance SqlCommand, containing the query and the query parameters.

Return Value

Type: DataSet
Exceptions

ExceptionCondition
SqlExceptionThe exception that is thrown when SQL Server returns a warning or error.
Examples

using (SqlClient c = new SqlClient())
{
  SqlCommand cmd = new SqlCommand("SELECT * FROM messages; SELECT * FROM users;");
  DataSet data = c.GetData(cmd);
  if(data.Tables.Count > 0)
  {
    foreach(DataTable t in data.Tables)
    {
      foreach(DataRow r in table.Rows)
      {
        Console.WriteLine("id = {0}", r["id"]);
      }
    }
  }
}
See Also