如何修复此过程或函数'view_users_schedule_report'需要参数'@id',这是未提供的。 [英] How to fix this procedure or function 'view_users_schedule_report' expects parameter '@id', which was not supplied.
本文介绍了如何修复此过程或函数'view_users_schedule_report'需要参数'@id',这是未提供的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请参考下面的SQL和Visual Basic代码...
我尝试过:
我的存储过程
Please refer to SQL and Visual Basic code below...
What I have tried:
my stored procedure
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文件
aspx.vb file
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
推荐答案
为什么要两次添加id字段?
Why do you add the id field twice?
cmd.Parameters.AddWithValue("@id", Request.QueryString("id"))
cmd.Parameters("@id").Value = Request.QueryString("id")
此外, Request.QueryString(id)
是否有值?您可以通过在行上设置断点并在执行前检查值来检查这一点。
Also, does Request.QueryString("id")
have a value? You can check this by setting a breakpoint on the line and check the value before executing.
这篇关于如何修复此过程或函数'view_users_schedule_report'需要参数'@id',这是未提供的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文