Executes a select statement or stored procedure and reads the first row of the returned record set

Namespace:  DbNetLink.Data
Assembly:  DbNetLink.DbNetData (in DbNetLink.DbNetData.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
public bool ExecuteSingletonQuery(
	string Sql
)
Visual Basic (Declaration)
Public Function ExecuteSingletonQuery ( _
	Sql As String _
) As Boolean
Visual C++
public:
bool ExecuteSingletonQuery(
	String^ Sql
)

Parameters

Sql
Type: System..::.String

The SQL statement

Return Value

Returns True if a record is found otherwise False

Examples

CopyC#
DbNetData Db = new DbNetData( ConfigurationManager.ConnectionStrings["nwind"] );
Db.Open();
if ( Db.ExecuteSingletonQuery("select productname from products where id = 1") )
    ProductName.Text = Db.ReaderValue("productname"); 
Db.Close();

See Also