Sqlserver--like参数加%
string sql = "select hr_key , user_id,user_name from hruser where user_id like @userid " ;
SqlConnection Sqlcon = new SqlConnection(ConfigurationManager.AppSettings["prConnection"]);
SqlCommand sqlComm = new SqlCommand(sql, Sqlcon);
// sqlComm.Parameters.Add("@userid", SqlDbType.VarChar);//添加参数
// sqlComm.Parameters.Add(new SqlParameter("@userid", string.Format("{0}%", tbUserId.Text)));
sqlComm.Parameters.Add(new SqlParameter("@userid", string.Format("{0}%", tbUserId.Text)));
//sqlComm.Parameters["@userid"].Value = tbUserId.Text ;//为参数赋值
Sqlcon.Open();
// sqlComm.ExecuteNonQuery();
//Sqlcon.Close();
SqlDataReader Dreader = sqlComm.ExecuteReader();
gvHrUser.DataSource = Dreader;
gvHrUser.DataBind();
Sqlcon.Close();