Executes the specified SqlCommand and returns DataTable.
Namespace: Nemiro.Data.SqlAssembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
public DataTable GetTable(
SqlCommand cmd
)
public DataTable GetTable(
SqlCommand cmd
)
Public Function GetTable (
cmd As SqlCommand
) As DataTable
Public Function GetTable (
cmd As SqlCommand
) As DataTable
Parameters
- cmd
- Type: System.Data.SqlClient SqlCommand
Instance SqlCommand, containing the query and the query parameters.
Return Value
Type:
DataTableException | 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 users;");
DataTable table = c.GetTable(cmd);
foreach(DataRow row in table.Rows)
{
Console.WriteLine("login = {0}", row["login"]);
}
}
using (SqlClient c = new SqlClient())
{
SqlCommand cmd = new SqlCommand("SELECT * FROM users;");
DataTable table = c.GetTable(cmd);
foreach(DataRow row in table.Rows)
{
Console.WriteLine("login = {0}", row["login"]);
}
}
Using c As new SqlClient()
Dim cmd As New SqlCommand("SELECT * FROM users;")
Dim table As DataTable = c.GetTable(cmd)
For Each row As DataRow In table.Rows
Console.WriteLine("login = {0}", row("login"))
Next
End Using
Using c As new SqlClient()
Dim cmd As New SqlCommand("SELECT * FROM users;")
Dim table As DataTable = c.GetTable(cmd)
For Each row As DataRow In table.Rows
Console.WriteLine("login = {0}", row("login"))
Next
End Using