private void btnSearch_Click(object sender, EventArgs e) { this.lvResult.Items.Clear(); //模糊查询 StudentDAL stu = new StudentDAL(); string s = txtStudentName.Text; stu.fin(s); ListViewItem item = new ListViewItem(stu.studentNo); item.SubItems.Add(stu.studentName); item.SubItems.Add(stu.gender); item.SubItems.Add(stu.gradeName); lvResult.Items.Add(item); }
public class StudentDAL { public bool addstudent(string LoginPwd, string StudentName, string Gender, int GradeId, string Phone, string Address, DateTime Birthday, string Email) { bool fan = false; string str = lianjieDAL.sql; SqlConnection conn = new SqlConnection(str); string sql = @"insert into[Student] ([LoginPwd] ,[StudentName] ,[Gender] ,[GradeId] ,[Phone] ,[Address] ,[Birthday] ,[Email]) values ('" + LoginPwd + "','" + StudentName + "','" + Gender + "','" + GradeId + "','" + Phone + "','" + Address + "','" + Birthday + "','" + Email + "')"; SqlCommand comm = new SqlCommand(sql,conn); conn.Open(); int cout = comm.ExecuteNonQuery(); conn.Close(); if (cout>0) { fan = true; } return fan; }
C#绑定ListViewItem
最新推荐文章于 2024-06-18 13:31:44 发布