本文介绍了参数没有默认值,请帮帮我.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,请帮帮我
我有以下代码



Hi Guys, Please help me out
I am having the following code



<body>
    <form id="form1" runat="server">
    <div>
    <div>
        &nbsp;Have Pan Card:
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="316px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

             <asp:ListItem>-----select----- </asp:ListItem>

            <asp:ListItem>yes</asp:ListItem>

            <asp:ListItem>no</asp:ListItem>

        </asp:DropDownList><br />
        &nbsp;</div>
    <div id="div1" runat="server">Enter Ist Choice &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div>


    </div>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </form>
</body>







后面的代码在这里







and the code behind is here

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class demo : System.Web.UI.Page
{
    string pan, panno;
    OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["adbudhconnection"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        div1.Visible = false;

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        con.Open();
        OleDbCommand cmd = new OleDbCommand("insert into demo(pan,panno)values(@pan,@panno)", con);
        cmd.Parameters.AddWithValue("@pan", pan);
        cmd.Parameters.AddWithValue("@panno", panno);
        cmd.ExecuteNonQuery();
        con.Close();
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedItem.Text == "yes")
        {
            div1.Visible = true;
           pan = DropDownList1.SelectedItem.Text;
            panno = TextBox1.Text;

        }
         else if (DropDownList1.SelectedItem.Text == "no")

        {

           pan = DropDownList1.SelectedItem.Text;
           panno = "n/a";

        }

    }
}



这给出了错误,
参数@pan没有默认值

请帮助



this gives the error that
Parameter @pan has no default value

please help

推荐答案


这篇关于参数没有默认值,请帮帮我.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 18:18