?
Solved

Procedure 'usp_GetDatePeriodFromTo' expects parameter '@YEARMONTH', which was not supplied.

Posted on 2007-03-28
5
Medium Priority
?
261 Views
Last Modified: 2013-11-25
I am using the enterpriselib 2.0

Public Function GetBusinessCalendarPeriod(ByVal DatePeriod As String) As DataTable
           ' DatePeriod is the YearMonth
            Dim retVal As New DataTable("BusinessCalendars")

            Dim cmd As DbCommand
            Dim tmpds As DataSet

            Try
                'We get the divisions
                cmd = dbManager.GetStoredProcCommand("SENZA.dbo.usp_GetDatePeriodFromTo")

                'Temporarilly put the results in a dataset so we can check for valid data
                tmpds = dbManager.ExecuteDataSet(cmd)

                'We must ensure that only one table was returned in the execution of the query
                If tmpds.Tables.Count.Equals(1) Then

                    'We also need to ensure that there is data
                    If tmpds.Tables(0).Rows.Count > 0 Then

                        retVal = tmpds.Tables(0)

                    Else
                        Return retVal
                    End If
                Else
                    Return retVal
                End If

            Catch ex As Exception
                Throw ex
            Finally
                'Cleaning up
                If Not tmpds Is Nothing Then
                    tmpds.Dispose()
                End If

                If Not cmd Is Nothing Then
                    cmd.Dispose()
                End If

            End Try

            Return retVal
        End Function
Procedure 'usp_GetDatePeriodFromTo' expects parameter '@YEARMONTH', which was not supplied.

Private Sub cmdProceed_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdProceed.Click
        _calendar.GetBusinessCalendarPeriod(txtPeriod.Text)
        Response.Write("Calendar")
    End Sub
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
  • 2
5 Comments
 
LVL 16

Expert Comment

by:rboyd56
ID: 18810612
Basically the stored procedure you are calling requires the @YEARMONTH parameter and you are not passing it with this command:

 cmd = dbManager.GetStoredProcCommand("SENZA.dbo.usp_GetDatePeriodFromTo")

 'Temporarilly put the results in a dataset so we can check for valid data
  tmpds = dbManager.ExecuteDataSet(cmd)
0
 

Author Comment

by:mathieu_cupryk
ID: 18810685
I am new to this EL 2.0 how do I go about doing so?
0
 
LVL 16

Expert Comment

by:rboyd56
ID: 18810804
You can probably change your code to this. I believe this will do it.


cmd = dbManager.GetStoredProcCommand("SENZA.dbo.usp_GetDatePeriodFromTo")
dbmanager.AddInParameter(cmd, "Year and Month", DbType.DateTime, New DateTime(1997, 1, 1))
'Temporarilly put the results in a dataset so we can check for valid data
  tmpds = dbManager.ExecuteDataSet(cmd)


0
 

Author Comment

by:mathieu_cupryk
ID: 18810857
Dim retVal As New DataTable("BusinessCalendars")

            Dim cmd As DbCommand
            Dim tmpds As DataSet

            Try
                'We get the divisions
                cmd = dbManager.GetStoredProcCommand("SENZA.dbo.usp_GetDatePeriodFromTo")

                dbManager.AddInParameter(cmd, "@YEARMM", DatePeriod)
               
                'Temporarilly put the results in a dataset so we can check for valid data
                tmpds = dbManager.ExecuteDataSet(cmd)

                'We must ensure that only one table was returned in the execution of the query
                If tmpds.Tables.Count.Equals(1) Then

                    'We also need to ensure that there is data
                    If tmpds.Tables(0).Rows.Count > 0 Then

                        retVal = tmpds.Tables(0)

                    Else
                        Return retVal
                    End If
                Else
                    Return retVal
                End If

            Catch ex As Exception
                Throw ex
            Finally
                'Cleaning up
                If Not tmpds Is Nothing Then
                    tmpds.Dispose()
                End If

                If Not cmd Is Nothing Then
                    cmd.Dispose()
                End If

            End Try

            Return retVal
        End Function

    End Class
0
 
LVL 16

Accepted Solution

by:
rboyd56 earned 2000 total points
ID: 18810896
Did that work?

If not, look at this URL for the proper syntax:

http://www.daveandal.net/articles/EntLibASPNET/EnterpriseLibraryInASPNET-2.htm
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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.
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.
Suggested Courses

762 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