Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-03-28
3
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:rboyd56
ID: 18809315
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 18809381
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
ID: 18810119
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

618 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