Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run Stored Procedure uisng ADO 5 20
changing page verifacation 1 25
query linked sql table field from access 4 20
job schedule 8 17
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

840 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