I have a search form which the user has to enter values to search for a particular vehicle in the database. I want to assign a certain value in the database to a certain control on another page. how will I be able to do this? I have something like this
protected void Search_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("MyConnectionString");
SqlParameter pm = new SqlParameter();
conn.Open();
string sql = "SELECT*FROM Vehicles WHERE Vehicle_Reg=@vReg";
string sql1 = "SELECT*FROM Trailer WHERE Trailer_Reg=@tReg";
string mySql = sql + sql1;
SqlCommand cmd = new SqlCommand(mySql, conn);
cmd.CommandText = mySql;
cmd.Parameters.AddWithValue("@vReg", searchtext.Text);
cmd.Parameters.AddWithValue("@tReg", chassisnum.Text);
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
//These TextBoxes are on another page
txtReg.Text = dr["Registration"].ToString();
txtMake.Text = dr["Make"].ToString();
txtEngineNum.Text=dr["EngineNumber"].ToString();
dr.Close();
}
conn.Close();
}