Hi justin,
No, you don't necessarily have to look at the Appointment booking app. However, if you were basing this on an existing app, it would be easier for me to show you code that plugs right into your application.
Basically what you need to do is this:
1. Create a stored procedure with an OUTPUT param. This sproc should select the result set AND fill in the OUTPUT param. You can use IF EXISTS in the query to see if the record already exists.
2. Next, you need to set up this param in the DAL and pass it into the Command object.
3. When the query is executed, get the resultset (a DataSet or a SqlDataReader) and get the value from the output param.
4. Give the method that calls this code a return type of the initial data (e.g. a User object, or a DataSet, or a List (Of Users), whatever is appropriate.) Also, if necessary, give it a ByRef param to indicate if the record already exists.
Now, this is the hard way to do things. You want to return an OUTPUT param AND a resultset at the same time. But maybe you can do this much simpler? What about this (pseudo code):
Public Function CheckUser(ByVal userId As Integer)
' Go into database
If the user exists in the database
Return New User(FirstName from database, LastName from database)
Else
Return Nothing
End If
End Function
Then in your calling code you can do this:
If CheckUser(someId) Is Nothing Then
' User is not on the bus
Else
Sorry, this user is already on the bus. Would you like to edit it?
End If
If you need help with the first scenario (or with the second), let me know. A verbose answer may take until the weekend as I don't much time earlier.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of
ASP.NET 2.0 Instant Results and
Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out
this post.