Mike:
When you say error, do you mean exception? The two aren't necessarily
interchangable. If your function generates an exception, if you simply
don't catch it, it'll bubble up to the to the aspx page which you can then
handle by explicitly catching or using the OnError event. If, for whatever
reason, you need to catch the exception in the function, you can rethrow it
(check out
http://dotnetguy.techieswithcats.com/archives/004118.shtml for
info on how to do that properly)
If you aren't talking about exceptions, simply an error, like the
username/password wasn't found, you can either throw an exception within the
function, throw new ApplicationException("invalid username/password"), or
you can simply using the function's return value. Both methods have
drawbacks...for example, an invalid username/password isnt' really something
exceptional and many people (myself included) would probably be against
using exceptions in this case. Return values can be very messy.
//mix of C# and vb.net so I can type this quicker

public function GetUser(string username, string password) as user
DataReader dr = cmd.executeReader()
if dr.Read() then
User u = new User()
u.UserName = dr(...);
return u
else
//what to do?
throw new ApplicationException("invalid username/password");
//or maybe:
return nothing //null in c#
//or maybe
User u = new User();
u.Status = UserStatus.InvalidUser //an enumeration
return u
end function
How you handle it on the page depends on which method you use. For return
values you'll need to check the value and handle it appropriately. For
exceptions you can wrap the call in a Try/Catch or simply rely on the
Page.Error event. You can also use the Global.Asax's Error event to trap
all errors.
Karl