Executes the query 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(
string sql
)
public DataTable GetTable(
string sql
)
Public Function GetTable (
sql As String
) As DataTable
Public Function GetTable (
sql As String
) As DataTable
Parameters
- sql
- Type: System String
Query SQL, to be executed.
Return Value
Type:
DataTableException | Condition |
---|
SqlException | The exception that is thrown when SQL Server returns a warning or error. |
using (SqlClient c = new SqlClient())
{
DataTable table = c.GetTable("SELECT * FROM users;");
foreach(DataRow row in table.Rows)
{
Console.WriteLine("login = {0}", row["login"]);
}
}
using (SqlClient c = new SqlClient())
{
DataTable table = c.GetTable("SELECT * FROM users;");
foreach(DataRow row in table.Rows)
{
Console.WriteLine("login = {0}", row["login"]);
}
}
Using c As new SqlClient()
Dim table As DataTable = c.GetTable("SELECT * FROM users;")
For Each row As DataRow In table.Rows
Console.WriteLine("login = {0}", row("login"))
Next
End Using
Using c As new SqlClient()
Dim table As DataTable = c.GetTable("SELECT * FROM users;")
For Each row As DataRow In table.Rows
Console.WriteLine("login = {0}", row("login"))
Next
End Using