-1

4 つのパラメーターを受け入れる DB にプロシージャーをストアドしました。このプロシージャーを SQLDatasource から呼び出し、そのパラメーターを sqldatasource ウィザードに渡すと、次のエラーが発生します。

エラー [42000] [Microsoft][ODBC SQL Server ドライバー][SQL Server] プロシージャまたは関数 'director_proc' には、指定されていないパラメーター '@Department' が必要です。

以下は、sqldatasource タグとストアド プロシージャのコードです。

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
SelectCommand="director_proc" SelectCommandType="StoredProcedure">
 <SelectParameters>
<asp:ControlParameter ControlID="ASPxComboBox1" DbType="String" 
DefaultValue="Enterprise solution" Name="Department" PropertyName="Value" 
Type="String" />
 <asp:ControlParameter ControlID="ASPxComboBox2" DbType="String" 
DefaultValue="Enterprise operations" Name="Section" PropertyName="Value" 
Type="String" />
<asp:ControlParameter ControlID="MonthEdit1" DbType="Int16" DefaultValue="7" 
Name="Month" PropertyName="Month" Type="Decimal" />
<asp:ControlParameter ControlID="ASPxComboBox3" DbType="Int16" 
 DefaultValue="2013" Name="Year" PropertyName="Value" Type="Decimal" />
 </SelectParameters>
</asp:SqlDataSource>

ストアド プロシージャ

    USE [AccessmgmtDB]
GO
/****** Object:  StoredProcedure [dbo].[director_proc]    Script Date: 10/08/2013 14:22:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[director_proc]
    -- Add the parameters for the stored procedure here
@Department nchar(50),
@Section nchar(50),
@Month numeric,
@Year numeric
AS
BEGIN
    if(@Section is null)
    SELECT SSNO ,Full_Name,152.5 [Working Hours],sum(diff) Actual_Hours,MONTH(date) as month,Year(date) Year
         ,(case when 152.5-sum([diff])<0 then 0 else 152.5-sum([diff])end) as [Missing Hours]
         ,(case when 152.5-sum([diff])<0 then 0 else (152.5-sum([diff]))/8.5 end) as [wanted days]
         ,section
         FROM attendance2
         where Department=@Department and MONTH ( date )=@Month and Year(date)=@Year
         group by SSNO,Full_Name,section,MONTH(date),Year(date) order by full_name;
         else
         SELECT SSNO ,Full_Name,152.5 [Working Hours],sum(diff) Actual_Hours,MONTH(date) as month,Year(date) Year
         ,(case when 152.5-sum([diff])<0 then 0 else 152.5-sum([diff])end) as [Missing Hours]
         ,(case when 152.5-sum([diff])<0 then 0 else (152.5-sum([diff]))/8.5 end) as [wanted days]
         ,section
         FROM attendance2
         where Department=@Department and MONTH ( date )=@Month and Year(date)=@Year and section=@Section
         group by SSNO,Full_Name,section,MONTH(date),Year(date) order by full_name;
END
4

4 に答える 4

0

問題は、DevExpress Combo Box にバインドしていることだと思います。AutoPostback="true"ASPxComboBox コントロールで設定してみてください。また、SqlDataSource が DevExpress コントロールと同じ名前付けコンテナーにあることを確認してください...過去に問題がありましたが、私は何年も使用していないので、それがまだあるかどうかはわかりません問題。

于 2013-10-08T15:22:12.747 に答える
0

SelectedItem.Valueコンボボックスのコントロール パラメータの値の代わりに使用してみてください。

 <SelectParameters>
      <asp:ControlParameter ControlID="ASPxComboBox1" DbType="String" 
       DefaultValue="Enterprise solution" Name="Department"  
       PropertyName="SelectedItem.Value" 
       Type="String" />
    <asp:ControlParameter ControlID="ASPxComboBox2" DbType="String" 
       DefaultValue="Enterprise operations" Name="Section"     
       PropertyName="SelectedItem.Value" 
       Type="String" />
   <asp:ControlParameter ControlID="MonthEdit1" DbType="Int16" DefaultValue="7" 
       Name="Month" PropertyName="Month" Type="Decimal" />
   <asp:ControlParameter ControlID="ASPxComboBox3" DbType="Int16" 
       DefaultValue="2013" Name="Year" PropertyName="SelectedItem.Value" Type="Decimal" />
    </SelectParameters>
于 2013-10-08T15:40:50.140 に答える