Click here to Skip to main content
15,897,891 members

Posting search results to textbox

ost3z asked:

Open original thread
hi guy i have a problem that i try every way to make Posting search results to textbox but always return nothing this is my code
C#
private void btnNamesearch_Click(object sender, EventArgs e)
      {

         bool temp = false;
          SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Educational System;Data Source=DREAMS");
          con.Open();
          SqlCommand cmd = new SqlCommand("SELECT EmpName, ExcutionOrder FROM Employee WHERE EmpName  ='" + txtusernameSearch.Text.Trim() + "'", con);
          SqlDataReader dr = cmd.ExecuteReader();
          while (dr.Read())
          {
              txtemployee.Text = dr["EmpName"].ToString();
              txtExcutionOrder.Text = dr["ExcutionOrder"].ToString();

              temp = true;
          }
          if (temp == false)
              MessageBox.Show("not found");

          con.Close();
          dr.Close();

      }

its work and when i make breakpoints it gets date but nothing display
and i have another problem that i have got 4 com boxes which fill in form load
suppose when i make search it should display the value of selected from search and this will make problem because it loads with form load ?? plz help really i think more but still need experiences through windows form thanks a lot
Tags: C#

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900