SqlConnection con = DB.sqlcon(); con.Open(); SqlCommand cmd = new SqlCommand( " select count(*) from [User] where [Name]=' " + TxtName.Text.Trim() + " ' " , con); int count = ( int )cmd.ExecuteScalar(); con.Close(); if (count >= 1 ) ... {; this.cue.Text = "用户已经被注册"; } else ... { this.cue.Text = "用户未被注册"; }