MyTextBox.Text="result of select";
will show result of select in your textbox.
Otherwise use the (DataBindings) property
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
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))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add(new SqlParameter("@InvNumber", 1100));
using (SqlDataReader dr = cmd.ExecuteReader())
{
dt.Load(dr);
}
}
conn.Close();
}
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
System.Diagnostics.Debugger.Break();
}
}
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735