<body >

How to retrieve the RETURN value from a stored procedure in .NET

Wednesday, November 21, 2007

If you need to return a single integer from a stored procedure, it's more efficient to use the RETURN statement than SELECT since SELECT is a whole recordset with a cursor. To access the return value from your C# code, you add a "ReturnValue" parameter to your stored procedure call:

(Pretend you have an open SqlConnection called "conn".)

SqlCommand sqlCommand = new SqlCommand("webmail_getMessageCount");
sqlCommand.Connection = conn;
sqlCommand.CommandType = CommandType.StoredProcedure;

SqlParameter messageCount = new SqlParameter("@count", SqlDbType.Int);
messageCount.Direction = ParameterDirection.ReturnValue;
sqlCommand.Parameters.Add(messageCount);

sqlCommand.ExecuteNonQuery();

return (int)messageCount.Value;

Labels: , ,

Permalink

Using Visual Studio.NET 2003 with FrontPage projects

Friday, October 12, 2007

  1. Tools > Options > Projects > Preferred access method: FrontPage Extensions
  2. New blank solution
  3. If you've never opened it in VS.Net, File > Add Project > New Project > Visual C# Projects > New Project in Existing Folder. If you have, File > Add Project > Existing from Web.
  4. Enter a name.
  5. Enter the URL of your project as the folder name to open. Provide login information.

Labels:

Permalink

 
   



Blogger Template by Gecko & Fly, modified by yours truly.