Member 13337364 Ответов: 1

Как исправить эту процедуру или функцию 'view_users_schedule_report' ожидает параметр '@id', который не был указан.


Пожалуйста, обратитесь к коду SQL и Visual Basic ниже...

Что я уже пробовал:

моя хранимая процедура
USE [HRIS_TADE]
GO
/****** Object:  StoredProcedure [dbo].[view_users_schedule_report]    Script Date: 31/07/2017 4:30:18 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[view_users_schedule_report]

@id varchar(36)

AS
 
BEGIN

		select b.time_start, b.time_end, b.no_of_working_hours, monday, tuesday, wednesday, thursday, friday, saturday, sunday, grace_period, (u.first_name + ' ' + u.last_name) AS fullname 
		,title,b.id,CONVERT(VARCHAR,date_hired,101) AS d_hired
		from users_schedule a LEFT JOIN users_schedule_types b
		ON a.schedule_id = b.id LEFT JOIN users u ON a.ecode = u.ecode where b.id=@id

END

aspx-файл.файл VB
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Partial Class view_schedule_report
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim crystalReport As New ReportDocument()
        crystalReport.Load(Server.MapPath("~/users_schedule_report.rpt"))
        Dim dsUsersSchedule As dsUsersSchedule = GetData2()
        crystalReport.SetDatabaseLogon("sa", "joniel22", "SHIEBC\JONIELSQLEXPRESS", "HRIS_TADE")
        crystalReport.SetDataSource(dsUsersSchedule)
        CrystalReportViewer1.ReportSource = crystalReport
        CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
        CrystalReportViewer1.Width = "300"
        CrystalReportViewer1.RefreshReport()
        crystalReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "Schedule Report" & Request.QueryString("id") & "")


    End Sub

    Private Function GetData2() As dsUsersSchedule
        Dim conString As String = ConfigurationManager.ConnectionStrings("TII").ConnectionString
        ' Dim cmd As New SqlCommand("ViewPayslip")

        Using con As New SqlConnection(conString)
            Using cmd As New SqlCommand("view_users_schedule_report", con)

                cmd.Parameters.AddWithValue("@id", Request.QueryString("id"))
                cmd.Parameters("@id").Value = Request.QueryString("id")
                cmd.CommandType = CommandType.StoredProcedure
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
                Using sda As New SqlDataAdapter()
                    cmd.Connection = con
                    cmd.CommandType = CommandType.StoredProcedure
                    sda.SelectCommand = cmd

                    Using dsJobDesc As New dsUsersSchedule
                        dsJobDesc.EnforceConstraints = False
                        sda.Fill(dsJobDesc, "dt_user_schedule")
                        Return dsJobDesc
                    End Using

                End Using
            End Using

        End Using
    End Function

End Class

1 Ответов

Рейтинг:
1

Graeme_Grant

Почему вы добавляете поле id дважды?

cmd.Parameters.AddWithValue("@id", Request.QueryString("id"))
cmd.Parameters("@id").Value = Request.QueryString("id")

Также делать Request.QueryString("id") есть ценность? Вы можете проверить это, установив точку останова на линии и проверив значение перед выполнением.