<asp:dropdownlist id="DropDownList1" runat="server" Width="320px">
<asp:ListItem Value=1>重要</asp:ListItem>
<asp:ListItem Value=2>一般</asp:ListItem>
<asp:ListItem Value=3>最后</asp:ListItem>
</asp:dropdownlist>
---------------------------------------------------------------------
............
OleDbCommand mycommand=new OleDbCommand("sp_insertinto",conn);
mycommand.CommandType=CommandType.StoredProcedure;
mycommand.Parameters.Add(new OleDbParameter("@Step",OleDbType.Char,10));
mycommand.Parameters["@Step"].Value=DropDownList1.SelectedItem.Value;
............调试没报错,但没成功插入数据。

解决方案 »

  1.   

    private void IB_Sure_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
    string memb_id=T_Acc.Text.Trim();
    string memb_pass=T_Pass.Text.Trim();
    string memb_name=T_Name.Text.Trim();
    string f_ques=T_Ques.Text.Trim();
    string f_answ=T_Answ.Text.Trim();
    string email=T_Mail.Text.Trim();
    string sno=T_SFZ.Text.Trim();
    string mess = "尊敬的朋友,欢迎您的注册!<BR>您的帐号名是:"+memb_id+",请您不要遗忘,以免不能登陆,感谢您对本站的支持,谢谢!";
    DateTime t=DateTime.Now;
    DateTime t1 = DateTime.Parse("2006-12-31 23:59:00");
    int money = Int32.Parse(LB_Money.Text.Trim()); string VNum;
    VNum=Session["VNum"].ToString();        
    ViewState["VNum"]=VNum; if (T_YZM.Text == ViewState["VNum"].ToString())
    {
    //创建并打开数据库
    SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
    myConnection.Open();

    SqlCommand myC = new SqlCommand("WEB_UserRegID",myConnection);
    myC.CommandType = CommandType.StoredProcedure;
    SqlParameter Pmemb___id = new SqlParameter("@memb___id",SqlDbType.VarChar,10);
    Pmemb___id.Value = memb_id;
    myC.Parameters.Add(Pmemb___id); SqlParameter Pmemb__pwd = new SqlParameter("@memb__pwd",SqlDbType.VarChar,10);
    Pmemb__pwd.Value = memb_pass;
    myC.Parameters.Add(Pmemb__pwd); SqlParameter Pmemb_name = new SqlParameter("@memb_name",SqlDbType.VarChar,10);
    Pmemb_name.Value = memb_name;
    myC.Parameters.Add(Pmemb_name); SqlParameter Psno__numb = new SqlParameter("@sno__numb",SqlDbType.VarChar,18);
    Psno__numb.Value = sno;
    myC.Parameters.Add(Psno__numb); SqlParameter Pfpas_ques = new SqlParameter("@fpas_ques",SqlDbType.VarChar,50);
    Pfpas_ques.Value = f_ques;
    myC.Parameters.Add(Pfpas_ques); SqlParameter Pfpas_answ = new SqlParameter("@fpas_answ",SqlDbType.VarChar,50);
    Pfpas_answ.Value = f_answ;
    myC.Parameters.Add(Pfpas_answ); SqlParameter Pemail = new SqlParameter("@mail_addr",SqlDbType.VarChar,50);
    Pemail.Value = email;
    myC.Parameters.Add(Pemail); SqlParameter Pmess = new SqlParameter("@mess",SqlDbType.VarChar,500);
    Pmess.Value = mess;
    myC.Parameters.Add(Pmess); SqlParameter Pmoney = new SqlParameter("@money",SqlDbType.Int,4);
    Pmoney.Value = money;
    myC.Parameters.Add(Pmoney); SqlParameter Prtn = new SqlParameter("@rtn",SqlDbType.VarChar,100);
    Prtn.Direction = ParameterDirection.Output;
    myC.Parameters.Add(Prtn);

    //myConnection.Open();
    myC.ExecuteNonQuery();
    myConnection.Close();
    string temp = Prtn.Value.ToString();
    if (temp == "ok")
    {
    p1.Visible=false;
    p2.Visible=true;
    LB_Id.Text = memb_id;
    LB_Name.Text = memb_name;
    LB_Mail.Text = email;
    LB_Ques.Text = f_ques;
    LB_Sno.Text = sno;
    }
    else
    {
    p1.Visible=false;
    p3.Visible=true;
    LB_error.Text=temp;
    }

    }
    else
    {
    Response.Write("<script>alert('验证码输入错误或失效,请核对后重新输入!')</script>");
    }
    }
    这是一段完整的代码..看了后你一定会.假如再不会.再发贴提问.
      

  2.   

    string strSql="exec 存储过程名称  参数1,参数2,......."private int ExeProcedure(string strSql)
    { Config config=new Config();
    CNN=new SqlConnection(config.getConnectionString());
    if (CNN.State !=ConnectionState.Open)
    {
    CNN.Open();
    }
    SqlCommand command=new SqlCommand(strSql,CNN);
    command.CommandType =CommandType.Text;
    return command.ExecuteNonQuery();
    }
      

  3.   

    OleDbCommand mycommand=new OleDbCommand("sp_insertinto",conn);
    mycommand.CommandType=CommandType.StoredProcedure;
    mycommand.Parameters.Add(new OleDbParameter("@Step",OleDbType.Char,10));
    mycommand.Parameters["@Step"].Value=DropDownList1.SelectedItem.Value;----------------------------------------------------------------------------多也没有看出什么问题.DropDownList1.SelectedItem.Value  是不是要再转一下数据类型....CHAR什么的....
    别的我真的没有看出什么来着...哈....