过程或函数'AddElection'需要参数'@Election_Start',这是未提供的。 [英] Procedure or function 'AddElection' expects parameter '@Election_Start', which was not supplied.

查看:63
本文介绍了过程或函数'AddElection'需要参数'@Election_Start',这是未提供的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的应用程序时,此消息显示过程或函数'AddElection'期望参数'@Election_Start',这是未提供的。



这是我的代码



When i run my application this message shows up"Procedure or function 'AddElection' expects parameter '@Election_Start', which was not supplied."

Here is my code

 <head>
  <meta charset="utf-8" />
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
      $(function () {
          $("#datepicker").datepicker();
          $("#datepicker1").datepicker();
          $("#datepicker2").datepicker();
          $("#datepicker3").datepicker();
      });
  </script>
</head>

    
       <table title="Election." cellspacing="0" cellpadding="6" border="0" id="Table1" style="background-color: White; height: 100%; width: 100%; font-family: Verdana; font-size: 0.8em; border-collapse: collapse;">
        <tr>
            <td align="center" style="color: White; background-color: #284775; font-weight: bold; height: 2em;">ELECTION</td>
        </tr>
      
       <tr>
           <td>
               <table border="0" cellpadding="2" style="width: 500px;">

                   <tr>
                       <td style="color: #5D7B9D;" align="center">Election Name:</td>
                       <td>
                           <asp:textbox id="txtElectionName" autopostback="true" runat="server" style="color: #5D7B9D; width: 150px; border-color: #5D7B9D; border-width: 1px; border-style: Solid;"></asp:textbox>
                           
                       </td>
                   </tr>
                   <%-- Election start date here --%>
                   <tr>
                       <td style="color: #5D7B9D;" align="center">Election Start Date:</td>
                       <td>                       
                           <input type="text" id="datepicker" />
                          <%-- <asp:TextBox ID="txtElectionStartDate"  runat="server" Style="color: #5D7B9D; width: 150px; border-color: #5D7B9D; border-width: 1px; border-style: Solid;"></asp:TextBox>--%>
                           <asp:ImageButton ID="ImageButton1" Width="25px" Height="25px" runat="server" OnClick="ImageButton1_Click" ImageUrl="~/Images/cal.jpg" />

                          
                       </td>
                   </tr>

                     <tr>
                       <td style="color: #5D7B9D;" align="center">Election End Date:</td>
                       <td>
                           <input type="text" id="datepicker1" />
                          <%-- <asp:TextBox ID="txtElectionStartDate"  runat="server" Style="color: #5D7B9D; width: 150px; border-color: #5D7B9D; border-width: 1px; border-style: Solid;"></asp:TextBox>--%>
                           <asp:ImageButton ID="ImageButton2" Width="25px" Height="25px" runat="server" OnClick="ImageButton1_Click" ImageUrl="~/Images/cal.jpg" />

                          
                       </td>
                   </tr>

                     <tr>
                       <td style="color: #5D7B9D;" align="center">Adding a Party Start Date:</td>
                       <td>
                           <input type="text" id="datepicker2" />
                          <%-- <asp:TextBox ID="txtElectionStartDate"  runat="server" Style="color: #5D7B9D; width: 150px; border-color: #5D7B9D; border-width: 1px; border-style: Solid;"></asp:TextBox>--%>
                           <asp:ImageButton ID="ImageButton3" Width="25px" Height="25px" runat="server" OnClick="ImageButton1_Click" ImageUrl="~/Images/cal.jpg" />

                          
                       </td>
                   </tr>

                     <tr>
                       <td style="color: #5D7B9D;" align="center">Adding a Party End Date:</td>
                       <td>
                           <input type="text" id="datepicker3" />
                          <%-- <asp:TextBox ID="txtElectionStartDate"  runat="server" Style="color: #5D7B9D; width: 150px; border-color: #5D7B9D; border-width: 1px; border-style: Solid;"></asp:TextBox>--%>
                           <asp:ImageButton ID="ImageButton4" Width="25px" Height="25px" runat="server" OnClick="ImageButton1_Click" ImageUrl="~/Images/cal.jpg" />

                          
                       </td>
                   </tr>
 <tr>
                       <td align="right">
                           <br />
                           <asp:Label ID="lblResults" runat="server" Text=""></asp:Label>
                           <asp:Button ID="AddElection" runat="server" Text="Submit" OnClick="AddElection_Click" Style="color: white; width: 100px; background-color: #284775; border-color: #5D7B9D; border-width: 1px; border-style: Solid;" />
                       </td>
                   </tr>

               </table>
           </td>
       </tr>
    </table>





我的DataAccessLayer





My DataAccessLayer

public void AddElections(NewElection newElection)
      {
          using (SqlConnection con = new SqlConnection(ConnString))
          {
              SqlCommand cmd = new SqlCommand("AddElection", con);
              cmd.CommandType = CommandType.StoredProcedure;

              cmd.Parameters.AddWithValue("@Election_Name" ,newElection.ElectionName);
              cmd.Parameters.AddWithValue("@Election_Start", newElection.ElectionStart);
              cmd.Parameters.AddWithValue("@Election_End", newElection.ElectionEnd);
              cmd.Parameters.AddWithValue("@Party_Start", newElection.PartyStart);
              cmd.Parameters.AddWithValue("@Party_End", newElection.PartyEnd);
              con.Open();
              cmd.ExecuteNonQuery();
          }
      }





我的代码



My code behind

protected void AddElection_Click(object sender, EventArgs e)
    {
       String datep = Request.Form["datepicker"];
       String datep1 = Request.Form["datepicker1"];
       String datep2 = Request.Form["datepicker2"];
       String datep3 = Request.Form["datepicker3"];
        
        System.Web.UI.HtmlControls.HtmlInputControl datepickerControl = this.FindControl("datepicker") as System.Web.UI.HtmlControls.HtmlInputControl;



        NewElection elec = new NewElection(txtElectionName.Text, datep, datep1, datep2, datep3);
        elections.AddElections(elec);
        
       Request["datepicker1"].ToString(), Request["datepicker2"].ToString(), Request["datepicker3"].ToString());
    }

推荐答案

(function(){
(function () {


#datepicker)。datepicker();
("#datepicker").datepicker();


#datepicker1)。datepicker();
("#datepicker1").datepicker();


这篇关于过程或函数'AddElection'需要参数'@Election_Start',这是未提供的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆