jwcolby
jwcolby at colbyconsulting.com
Mon Nov 30 12:25:27 CST 2009
James, So what does this do for me? int retValue = sCmd.ExecuteNonQuery(); From my Googling it seems like I have to do something like: retValue = Int32.Parse(sCmd.Parameters["@Return_Value"].Value.ToString()); which is working just fine. scmd.ExecuteNonQuery() returns a -1 (not sure why) and then the @Return_Value is parsed and returned. So that part is now working as well. Thanks again for the response James. John W. Colby www.ColbyConsulting.com James Barash wrote: > John: > > You do, indeed, need to define a Parameter for the return value. From the Microsoft documentation: > > SqlCommand.ExecuteNonQuery Method > > Executes a Transact-SQL statement against the connection and returns the number of rows affected. > > To add a Return Value parameter: > > SqlParameter ret = new SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int); > ret.Direction = ParameterDirection.ReturnValue; > cmd.Parameters.Add(ret); > > Hope this helps.