string str = "select * from 表 where 列名='" + txtname.Text.Trim() + "'"; SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]); conn.Open(); SqlCommand comm = new SqlCommand(str, conn); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read()) {输出有的信息} else {输出没有的信息}