C#实现数据库多条件查询 20
代码如下:能运行不报错但是点击查询没有任何反应Stringbookname=this.textBox1.Text.Trim();Stringbookid=this.tex...
代码如下:能运行不报错但是点击查询没有任何反应String bookname = this.textBox1.Text.Trim(); String bookid = this.textBox2.Text.Trim(); String author = this.textBox3.Text.Trim(); String press = this.textBox4.Text.Trim(); SqlConnection cnn; cnn = new SqlConnection("server=(local)\\SQLEXPRESS;uid=sa;pwd=111111;database=图书管理系统"); cnn.Open(); String find = "select 书名,图书编号,作者,出版社" + "from 图书" + "where 1=1"; if (bookname.Length != 0) { find += "and 书名=" + bookname; } else if (bookid.Length != 0) { find += "and 图书编号=" + bookid; } else if (author.Length != 0) { find += "and 作者=" + author; } else if (press.Length != 0) { find += "and 出版社=" + press; }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |