2016-12-02 5 views
0

を供給していなかった私は、このエラーを取得しておく、私は、Visual Studio 2016およびMicrosoft Management StudioのSQL Serverと働いている2016年プロシージャまたは関数「procMakeTimeSlotは」パラメータを期待「@userFriendlyErorrMessage」、

プロシージャまたは関数 'procMakeTimeSlot'は、パラメータ '@userFriendlyErorrMessage'を要求しますが、これは指定されていません。

command.ExecuteNonQuery(); //.Net says anything not select operation is a non query 

    create proc procMakeTimeSlot 
    (
     @appointmentId int, 
     @appointmentSlotId int, 
     @userFriendlyErorrMessage varchar(100) output 

    ) 
    as 
    begin 


    declare @successfulInsert bit; 

    begin try 

    insert into ApptTimePeriod 
    (AppointmentId, AppointmentSlotId) 
    values 
    (@appointmentId, @appointmentSlotId) 

     set @userFriendlyErorrMessage = 'Successful'; 

     set @successfulInsert = 1; 

    end try 

    begin catch 
    --primary key error 

     if (ERROR_MESSAGE() like'%pkApptTimePeriod%') 

     set @userFriendlyErorrMessage = 'Appointment has already been added to the time slot' 


     if(ERROR_MESSAGE() like 

'%fkAppointmentTimePeriodToAppointmentSlot%') 

     set @userFriendlyErorrMessage = 'Invalid Time Slot'; 

      if(ERROR_MESSAGE() like '%fkAppointmentTimePeriodToAppointment%') 

      set @userFriendlyErorrMessage = 'Invalid Appointment'; 


        if(ERROR_MESSAGE() like '%chSlotsLeft%') 

         set @userFriendlyErorrMessage = 'No time Slots Available'; 

         set @successfulInsert = 0; 

         end catch 

         return @successfulInsert;  
    end 

/* 


declare @userFriendlyErorrMessage varchar(100); 

execute procMakeTimeSlot 

@appointmentId = 10005, 

@appointmentSlotId = 100, 

@userFriendlyErorrMessage = @userFriendlyErorrMessage output; 

print @userFriendlyErorrMessage; 



<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FindServiceAvailability.aspx.cs" Inherits="VehicleServiceWebAppMcConnell.FindServiceAvailability" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 

<asp:Calendar ID ="calStartDate" Caption ="Choose start date (optional)" runat="server" /> 

    <asp:Calendar ID ="calEndDate" Caption ="Choose end date (optional)" runat="server" /> 

<asp:Button ID ="btnFindServiceAvailability" Text ="Find Service Availability" runat ="server" OnClick="btnFindServiceAvailability_Click" /> 

<asp:GridView ID ="gvAvailableServiceTimes" Caption = "Available Service Dates and Times" runat ="server" AutoGenerateColumns ="False" EmptyDataText = "No availability for requested date/time" > 

<Columns> 

    <asp:TemplateField HeaderText ="Select Date and Times"> 

     <ItemTemplate> 

      <asp:CheckBox ID ="cbSelectedDateTime" runat = "server" /> 

     </ItemTemplate> 

    </asp:TemplateField> 

    <asp:BoundField DataField ="AppointmentSlotId" HeaderText ="Appointment Slot ID" /> 
    <asp:BoundField DataField ="ApptDate" DataFormatString = "{0:d}" HeaderText ="Available Date" /> 
    <asp:BoundField DataField ="ApptTime" HeaderText ="Start Time" /> 


</Columns> 

</asp:GridView> 

<asp:Button ID ="btnMakeAppointment" Text ="Make Appointment" runat ="server" OnClick="btnMakeAppointment_Click" /> 

<asp:Label ID ="lblResultMessage" runat ="server" /> 

</asp:Content> 
+0

あなたの.Netコードはどこですか?あなたは@userFriendlyErorrMessageのために何を渡していますか? – Seano666

+0

私はAppointmentSlotIdがprocMakeTimeSlotのMicrosoft管理スタジオ(SQL)の自分の手続きで正しく入力されていることを知っています – Student

+0

私の視覚スタジオコードを見る必要があるかどうか教えてください。あるいは、ソリューション全体でさえ、私の友人の非常に小さなエラーが、私がvarcharとしてuserfriendlyerrormessageを宣言しなければならないと言いましたが、私はすでにそれを行っていますか?多分私はビジュアルスタジオでそれをやる必要がありますか? – Student

答えて

0

代わりの

@userFriendlyErorrMessage varchar(100) output 

GETDATE DATE SETの@GETDATETIME = GETDATE(@この

@userFriendlyErorrMessage varchar(100) = null output 
+0

私はデバッグを外して再構築/開始するときに同じエラーが発生しているとお考えになりました。 – Student

+0

コードの後ろにコードを共有:) – Abishek

+0

またはElse Remove Output Parameterを選択し、select文を使用して値を返そうとします。ちょうど以下のような – Abishek

0

DECLAREの@GETDATETIMEのDATETIMEを、使用してみてください) SET @ GETDA TE = CONVERT(DATE、GETDATE()、105) DATETIMEとして@GETDATETIMEを選択し、@ GETDATEをDATEに設定します。

tryこのように出力パラメータを削除し、Select文を使用して出力を返します。私が言及したサンプル

+0

ちょうど助けのためのスペルミスのおかげでエラーとerorrがuserfriendlyerrormessageに混在していた – Student

関連する問題