Hi All,

Actually i want to dispaly the results of a select statement in a TextBox. Pls anyone give me an idea how to do it.


MyTextBox.Text="result of select";
will show result of select in your textbox.
Otherwise use the (DataBindings) property

private void button1_Click(object sender, EventArgs e)
      const string connStr = "Data Source=apex2006sql;Initial Catalog=Leather;Integrated Security=True;";
      const string query = "Select * From Invoice Where InvNumber = @InvNumber";
      using (DataTable dt = new DataTable())
        using (SqlConnection conn = new SqlConnection(connStr))
          using (SqlCommand cmd = new SqlCommand(query, conn))
            cmd.Parameters.Add(new SqlParameter("@InvNumber", 1100));
            using (SqlDataReader dr = cmd.ExecuteReader())
        if (dt.Rows.Count != 1)
          throw new Exception("Record not found!");
        DataRow row = dt.Rows[0];
        int invNumber = Convert.ToInt32(row["InvNumber"]);
        string invStatus = Convert.ToString(row["InvStatus"]);
        //Bind the text boxes after you have the values