Solved

Need to create a routine to call the stored proc above in vb.net.

Posted on 2007-03-28
3
179 Views
Last Modified: 2010-04-23
Can someone help me get started in vb.net asp.net
to call the below proc.



CREATE PROCEDURE usp_GetDatePeriodFromTo
      @YEARMONTH VARCHAR(6)
AS

DECLARE @YEAR_NO int
SET @YEAR_NO = CAST(LEFT(@YEARMONTH,4) as INT)
DECLARE @MONTH_NO int
SET @MONTH_NO = CAST(RIGHT(@YEARMONTH,2) as INT)

SELECT *
FROM (
      SELECT
           
            CONVERT(int,CONVERT(varchar, @YEAR_NO)+right  ( '00' + CAST(@MONTH_NO AS VARCHAR(2)) ,2))

             AS PERIOD_NBR,
            MIN(STRT_DTTM) AS BEGIN_PRD,
            MAX(END_DTTM) AS END_PRD
      FROM BUSINESS_CALENDAR
      WHERE CONVERT(varchar(7),YR_NBR,112) = CAST(@YEAR_NO as varchar) and CASE PRD_NM
            WHEN 'Feb' THEN '1'
            WHEN 'Mar' THEN '2'
            WHEN 'Apr' THEN '3'
            WHEN 'May' THEN '4'
            WHEN 'Jun' THEN '5'
            WHEN 'Jul' THEN '6'
            WHEN 'Aug' THEN '7'
            WHEN 'Sep' THEN '8'
            WHEN 'Oct' THEN '9'
            WHEN 'Nov' THEN '10'
            WHEN 'Dec' THEN '11'
            WHEN 'Jan' THEN '12'END = @MONTH_NO
      GROUP BY PRD_NM
) T
ORDER BY PERIOD_NBR

Period_nbr    start date                            end date
200601      2006-01-29 00:00:00.000      2006-02-25 00:00:00.000
0
Comment
Question by:mathieu_cupryk
3 Comments
 
LVL 16

Expert Comment

by:rboyd56
Comment Utility
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
Hello mathieu_cupryk,

  a small tutorial is here:
  http://www.vbdotnetheaven.com/UploadFile/dclark/StoredProceduresinVBdotNET04082005072716AM/StoredProceduresinVBdotNET.aspx

  Dim cmdData As New SqlCommand("usp_GetDatePeriodFromTo", cnPubs)cmdAuthors.CommandType = CommandType.StoredProcedure

  cmdData.Parameters.Add("@yearmonth", SqlDbType.NVarChar, 6)
  cmdAuthors.Parameters("@yearmonth").Value = "200701"
  ....


Regards,

angelIII
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
I just setup
In my default page I have this?
Imports CustomerList.BOL
 Private _calendar As New BusinessCalendar()

 Protected Sub cmdProceed_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdProceed.Click
        _calendar.GetBusinessCalendarPeriod(txtPeriod.Text)
    End Sub

where txtPeriod = YYYYMM

  Namespace CustomerList.BOL

    Public Class BusinessCalendar

        Public Shared Function GetBusinessCalendarPeriod(ByVal DatePeriod As String) As DataSet
            Dim db As DBAccess = New DBAccess
            db.AddParameter("@YEARMONTH", DatePeriod)
            Return db.ExecuteDataSet("usp_GetDatePeriodFromTo")
        End Function

    End Class

End Namespace

C:\SourceControl_mcupryk\InHouseDev\APPS\MKT0003 - CustomerList\src\CustomerList\MainPage.aspx.vb(58,0): warning BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now