Executes the specified SqlCommand and returns DataSet.
Namespace: Nemiro.Data.SqlAssembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
public DataSet GetData(
SqlCommand cmd
)
public DataSet GetData(
SqlCommand cmd
)
Public Function GetData (
cmd As SqlCommand
) As DataSet
Public Function GetData (
cmd As SqlCommand
) As DataSet
Parameters
- cmd
- Type: System.Data.SqlClient SqlCommand
Instance SqlCommand, containing the query and the query parameters.
Return Value
Type:
DataSetException | Condition |
---|
SqlException | The exception that is thrown when SQL Server returns a warning or error. |
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"]);
}
}
}
}
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"]);
}
}
}
}
Using c As new SqlClient()
Dim cmd As New SqlCommand("SELECT * FROM messages; SELECT * FROM users")
Dim data As DataSet = c.GetData(cmd)
If data.Tables.Count > 0 Then
For Each t As DataTable In data.Tables
For Each r As DataRow In table.Rows
Console.WriteLine("id = {0}", row("id"))
Next
Next
End If
End Using
Using c As new SqlClient()
Dim cmd As New SqlCommand("SELECT * FROM messages; SELECT * FROM users")
Dim data As DataSet = c.GetData(cmd)
If data.Tables.Count > 0 Then
For Each t As DataTable In data.Tables
For Each r As DataRow In table.Rows
Console.WriteLine("id = {0}", row("id"))
Next
Next
End If
End Using