Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Label to Display Output from Stored Procedure

Status
Not open for further replies.

DixieDean

Programmer
Nov 28, 2005
19
GB
Hello

Please help.

I am a total novice with VWDE, and would be most obliged if you could overlook my general ignorance and help me with this issue.

I have a web form called Demo.aspx which incorporates a label (DateRange) that I would like to display the earliest and latest dates when a user had entered records into a table (Events) within a SQL Server Express 2005 database (EventCalendar).

I have prepared the following stored procedure intended to extract these dates:

CREATE PROCEDURE sp_DataDonationDateRange
@UserCode nchar(10),
@EarliestDate nchar(10) OUTPUT,
@LatestDate nchar(10) OUTPUT
AS
SET @EarliestDate = (SELECT MIN(CONVERT(nchar(10), dbo.Events.EventDate, 103))
FROM dbo.Events
WHERE dbo.Events.UserCode = @UserCode)
SET @LatestDate = (SELECT MAX(CONVERT(nchar(10), dbo.Events.EventDate, 103))
FROM dbo.Events
WHERE dbo.Events.ClientCode = @CliCode)
GO

(The procedure has been tested and appears to run well, returning the following row when @UserCode is set to a relevant value:

01/01/2003, 31/12/2004

)


I want to execute this procedure (on Page_Load) to return the first and last dates when a user had entered Event records by running the following against the SQL database (Demo), with the intention of displaying the following sequence within the DateRange label:

“You have entered records from “ + @EarliestDate + “to “ + @LatestDate.”

The connection that I have set up in the Database Explorer is called “DemoConnectionString”.

I’ve scanned innumerable sources but with no success. No articles appear to encapsulate all of the tasks involved in one place, and I am extremely confused as to how best to approach this.

I would be very grateful if anyone could provide me with the correct vb code to apply to the form’s Page_Load event, or if they could direct me to an appropriate article on the web.

Many thanks in advance.

Regards

DixieDean
 
Can you give an example of what you've got so far as hen we can see where you may be going wrong?

Also, you might want to check out faq855-5662 on how to loop through data from a database (you can simply change the CommandType of the Command object if you want to use an SP instead).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the quick response.

I'm afraid I don't really have an example to offer, as I'm merely trying to understand how to get the DateRange label to display the string and the incorporated output values of the stored procedure. The truth is that I don't know where to start, as most of the articles I've found are way beyond my league.

I'll take a look at the link that you kindly provided, and see if there's anything that may help me there, but I guess what I;m looking for is some sort of template for linking the values returned by the stored procedure (i.e. its output parameter values) to the label on my web form (i.e. the DateRange label).

Many thanks for your help.

Regards

DixieDean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top