| c# Programming Glossary: executescalarHow can I determine whether a column exists in a SQL Server CE table with C#? http://stackoverflow.com/questions/15693639/how-can-i-determine-whether-a-column-exists-in-a-sql-server-ce-table-with-c  cmd.CommandText tblQuery object objvalid cmd.ExecuteScalar retVal null objvalid catch  retVal false return retVal ...but.. sure how to implement this in C# .NET 1.1 Do I need to use ExecuteScalar and cast the returned value to a bool Or something else UPDATE.. cmd.CommandText tblQuery object objvalid cmd.ExecuteScalar retVal Convert.ToBoolean objvalid catch  retVal false return.. 
 Handling ExecuteScalar() when no results are returned http://stackoverflow.com/questions/1999020/handling-executescalar-when-no-results-are-returned  ExecuteScalar when no results are returned  I am using the following SQL query.. are returned  I am using the following SQL query and the ExecuteScalar method to fetch data from an Oracle database sql select username.. from usermst where userid 2 string getusername command.ExecuteScalar It is showing me this error message System.NullReferenceException.. 
 How to insert a record and return the newly created ID using a single SqlCommand? http://stackoverflow.com/questions/330707/how-to-insert-a-record-and-return-the-newly-created-id-using-a-single-sqlcommand  text so that I get the newly created ID when I use the ExecuteScalar method  c# sql sql server   share improve this question   INSERT.. 
 c# isn't a Int64 equal to a long? http://stackoverflow.com/questions/5260314/c-sharp-isnt-a-int64-equal-to-a-long  based statements 'SELECT COUNT FROM X' and have been using ExecuteScalar to read these single valued results. However I ran into a issue.. a Long long recordCount 0 recordCount long selectCommand.ExecuteScalar Error is Specified cast is not valid. Update I can read BingInt.. 
 SQL: Update a row and returning a column value with 1 query http://stackoverflow.com/questions/700786/sql-update-a-row-and-returning-a-column-value-with-1-query  Name column with 1 plan access only I'm using C# ADO.NET ExecuteScalar or ExecuteReader methods.  c# sql server tsql ado.net   share.. 
 SCOPE_IDENTITY() always returning 0  http://stackoverflow.com/questions/8633821/scope-identity-always-returning-0  DbType.Int32 cmd.Parameters.Add param execute int id cmd.ExecuteScalar .ToInt return id if cn.State ConnectionState.Open cn.Close catch..  share improve this question   It looks like you are using ExecuteScalar and not looking at the output parameter to get the identity... your query. Here's a quick example which should work with ExecuteScalar CREATE PROCEDURE dbo.QuickExample @Name VARCHAR 50 AS INSERT.. 
 Unable to cast object of type 'System.DBNull' to type 'System.String` http://stackoverflow.com/questions/870697/unable-to-cast-object-of-type-system-dbnull-to-type-system-string  Guid id string accountNumber string DBSqlHelperFactory.ExecuteScalar connectionStringSplendidmyApp  CommandType.StoredProcedure .. Guid id object accountNumber  object DBSqlHelperFactory.ExecuteScalar connectionStringSplendidCRM   CommandType.StoredProcedure  .. accountNumber.ToString EDIT Haven't paid attention to ExecuteScalar. It does really return null if the field is absent in the return.. 
 C#: Pass a user-defined type to a Oracle stored procedure http://stackoverflow.com/questions/980421/c-pass-a-user-defined-type-to-a-oracle-stored-procedure  ...  .ConnectionString #endregion public static object ExecuteScalar string query  object result using OracleConnection conn new.. conn command.CommandType CommandType.Text result command.ExecuteScalar  command.Dispose  conn.Close  return result public static object..  conn.Close  return result public static object ExecuteScalar string query params object parameters  object result using OracleConnection.. 
 |