Solved

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

Posted on 2007-03-28
3
182 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
ID: 18809315
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with SQL Server Stoplist 2 17
Counting connections to SQL Server through C# 3 28
SQL Server Question 5 25
Need a starter for ETL protocol? 4 42
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

910 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

21 Experts available now in Live!

Get 1:1 Help Now