我想做一个查询, 界面是
,我根据书本上打,代码是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click1(object sender, EventArgs e)
{
string ConnStr = ConfigurationManager.ConnectionStrings["ConnString"].ToString(); //调用连接字符串
SqlConnection con = new SqlConnection(ConnStr);
SqlCommand cmd=new SqlCommand ("selectname",con );
cmd .CommandType=CommandType .StoredProcedure ;
cmd .Parameters .Add (new SqlParameter ("@uame",SqlDbType .NChar ,6));
cmd.Parameters["@uame"].Value = txtUserName.Text;
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
}
}
}
这时候出现一个错误。错误时
,为什么提示存在。我是根据书上打的啊