我有存储过程来显示我的数据库中的数据。使用 sql server 2008。我的存储过程如下
USE [RSUPDB]
GO
/****** Object: StoredProcedure [dbo].[spSPDMonStockProductHarian] Script Date: 07/11/2013 14:56:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[spSPDMonStockProductHarian]
-- Add the parameters for the stored procedure here
@Tanggal Smalldatetime,
@WHSID Int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT NoReff, ProductID,Qnty , CreatedBy, CreatedDate,
LastUpdatedBy, LastUpdatedDate, Computer, ComputerDate
FROM tblSPDTrnHasilProduksiDtl
Where CreatedDate=@Tanggal
END
我使用 vb.net 调用该存储过程,如下所示
Private Sub CmRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmRefresh.Click
Dim i As Integer
Dim strCon1 As String = "server='ip server'; database=database name; user=user;password=password;"
Dim cmd As SqlCommand = New SqlCommand("spSPDMonStockProductHarian", New SqlConnection(strCon1))
'cmd.CommandText = "SELECT * FROM tblSPDTrnHasilProduksiDtl"
With cmd
.Parameters.Add("@Tanggal", SqlDbType.SmallDateTime).Value = Format(CDate(DateTimePicker1.Value), "dd/MM/yyyy")
.Parameters.AddWithValue("@WhsID", CboWhs.SelectedValue)
.Parameters.AddWithValue("@NoReff", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(0).FormattedValue.ToString
.Parameters.AddWithValue("@ProductID", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(1).FormattedValue.ToString
.Parameters.AddWithValue("@Qnty", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(2).FormattedValue.ToString
.Parameters.AddWithValue("@CreatedBy", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(3).FormattedValue.ToString
.Parameters.AddWithValue("@CreatedDate", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(4).FormattedValue.ToString
.Parameters.AddWithValue("@LastUpdatedBy", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(5).FormattedValue.ToString
.Parameters.AddWithValue("@LastUpdatedDate", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(6).FormattedValue.ToString
.Parameters.AddWithValue("@Computer", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(7).FormattedValue.ToString
.Parameters.AddWithValue("@Computerdate", SqlDbType.VarChar).Value = Listdata.Rows(i).Cells(8).FormattedValue.ToString
.Connection.Open()
End With
Listdata.DataSource = cmd.ExecuteReader
Koneksi.Close()
Koneksi.Close()
End Sub
执行此程序时出现问题,消息仍然出错
过程或函数“spSPDMonStockProductHarian”需要参数“@Tanggal”,但未提供该参数
我没明白什么问题???这让我的头筹,所以任何解决方案都会感激!