急急急!asp.net数据查询结果无法显示,显示为“未实现该方法或操作”,求帮助
protectedvoidButton1_Click(objectsender,EventArgse){stringstrsql="Select*fromzhucewhe...
protected void Button1_Click(object sender, EventArgs e) {string strsql = "Select * from zhuce where 性别 Like @性别 AND 年龄 Like @年龄 AND 学历 Like @学历 AND 所在地 Like @所在地"; //创建数据库连接对象 SqlConnection conn = new SqlConnection(); //指定连接字串 conn.ConnectionString = ConfigurationManager.ConnectionStrings["friendsConnectionString"].ToString(); try { //尝试连接数据库 conn.Open(); SqlCommand comm = new SqlCommand(); comm.CommandText = strsql; comm.Connection = conn; //添加参数 SqlParameter para1 = new SqlParameter("@性别", SqlDbType.NVarChar); SqlParameter para2 = new SqlParameter("@年龄", SqlDbType.Int); SqlParameter para3 = new SqlParameter("@学历", SqlDbType.NVarChar); SqlParameter para4= new SqlParameter("@所在地", SqlDbType.NVarChar); para1.Value = RadioButtonList1.Text; para2.Value=DropDownList1.Text; para3.Value=DropDownList2.Text; para4.Value=DropDownList3.Text; comm.Parameters.Add(para1); comm.Parameters.Add(para2); comm.Parameters.Add(para3); comm.Parameters.Add(para4); using (SqlDataReader dr = comm.ExecuteReader()) { DataTable dt = new DataTable("zhuce"); dt.Load(dr); if (dt.Rows.Count
展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询