cmd.CommandType = CommandType.StoredProcedure;
你指明的是要调用存储过程,你没给出存储过程的名字,而你用的是sql语句,当然不识别了

解决方案 »

  1.   

    cmd.CommandType = CommandType.StoredProcedure;
    改成
    cmd.CommandType = CommandType.Text;
      

  2.   

    而且不应该是values吗,为什么是value
    这东西你直接放数据库里执行也一样执行不成功啊
      

  3.   

    asp.net数据库连接登录示例
     protected void btnLoad_Click(object sender, ImageClickEventArgs e)
        {
            HttpCookie cookie = Request.Cookies["CheckCode"];
            if (String.Compare(cookie.Value, txtVali.Text, true) != 0)
            {            Response.Write("<script lanuage=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>");
            }        else
            {
               DataSet ds = DB.reDs("select * from tb_HuenLian where UserName='" + txtUid.Text.Trim() + "' and PassWord='" + txtPwd.Text.Trim() + "'");
                int i = this.checkLogin(txtUid.Text, txtPwd.Text);
                if (i > 0)
                {
                    Session["id"] = ds.Tables[0].Rows[0][0].ToString();
                    Session["UserName"] = this.txtUid.Text;
                    Session["PassWord"] = this.txtPwd.Text;
                    Page.Response.Redirect("Yonghu.aspx");
                }
                else
                {
                    Response.Write("<script lanuage=javascript>alert('用户名称或密码错误!');location='javascript:history.go(-1)'</script>");
                }
            }//codego.net/tags/11/1/
        }
        public int checkLogin(string loginName, string loginPwd)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conn"]);
            SqlCommand myCommand = new SqlCommand("select count(*) from tb_HuenLian where UserName=@loginName and PassWord=@loginPwd", con);
            myCommand.Parameters.Add(new SqlParameter("@loginName", SqlDbType.NVarChar, 20));
            myCommand.Parameters["@loginName"].Value = loginName;
            myCommand.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.NVarChar, 50));
            myCommand.Parameters["@loginPwd"].Value = loginPwd;
            myCommand.Connection.Open();
            int i = (int)myCommand.ExecuteScalar();
            myCommand.Connection.Close();
            return i;
        }
      

  4.   

    value变成values,另外和user_password)
    隔开一个空格
    Insert into  Table(user_login,user_password) Values(@user_login,@user_password)
      

  5.   

    另外你确认下,你连的数据库里有没有 Table表
      

  6.   


    没有人告诉你改了只后你的代码完全“可以”了,你解决了你贴出的那个“Could not find stored procedure .....”异常,那么你这就贴出“下一个异常”求助别人。如果你有2个错误,人家帮你解决了第一个,你非要说人家“不可以”,人家以后就不帮你了。
      

  7.   


    没有人告诉你改了只后你的代码完全“可以”了,你解决了你贴出的那个“Could not find stored procedure .....”异常,那么你这就贴出“下一个异常”求助别人。如果你有2个错误,人家帮你解决了第一个,你非要说人家“不可以”,人家以后就不帮你了。第一次发帖子 不知道具体怎么整 ,多谢提醒 ,,今后注意!
      

  8.   

      cmd.CommandType = CommandType.StoredProcedure;你应该用存储过程