Solved

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

Posted on 2007-03-28
3
194 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

688 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