String strConnString =ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
String strQuery = "select Country from Customers where CustomerID =@CustomerID";
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@CustomerID", "111");
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
SqlDataReader sdr= cmd.ExecuteReader();
while (sdr.Read())
{
LinkButton1.Text = sdr[0].ToString();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
}