Client Interfaces Guide > Connecting to TDV Server through ADO.NET > Sample Code for Testing of an ADO.NET Driver > Select Data from a TDV Published Resource
 
Select Data from a TDV Published Resource
You can select the data from the TDV Server with a SQL statement such as:
select ProductName from products where ProductID=1111
To select data from a TDV published resource
1. Edit the following code to send the SQL:
public void TestExecuteScalar()
{
CompositeConnection conn = GetConnection();
try
{
CompositeCommand cmd = new CompositeCommand(); cmd.CommandText = "select ProductName from products where ProductID=1111";
cmd.Connection = conn;
String name = (String)cmd.ExecuteScalar();
Console.WriteLine("(ProductName:" + name + ",TestExecuteScalar)");
}
catch (Exception ex)
{
throw ex;
}
}
 
2. Call the cmd.ExecuteScalar method to get the object that locates the first row and first column in the result set of the ExecuteScalar.
3. Conversion to a recognized data type is necessary, because it is an Object type value.