11
Reply

What method is used by the Command classes to execute SQL statements that return single values?

Rohan  Rathore

Rohan Rathore

11y
1.7k
0
Reply

    ExecuteScalar

    ExecuteScalar();

    ExecuteScalar returns the first column of the first row in the result set returned by the query.

    cmd.ExecuteScalar();

    sqlcommand.executescalar()

    ExecuteScalar()

    ExecuteScaler() Method will be used for Single value.

    The ExecuteScalat method of the command object returns single values from the sql query. It return the first column of the first row of the query.

    SqlCommand.ExecuteScalar();

    Execute Scalar. var requruedResult=SqlCommand.ExecuteScalar(); It will return first row's first column value.

    SqlCommand.ExecuteScalar(); This return only a single value(that is the first column of the first row. Other values are ignored)Link: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspxAlso see this thread: http://www.c-sharpcorner.com/Interviews/answer/6397/define-execute-scalar