Couple of things to note here.
1. No need to open the connection when you are using
SqlDataAdapter
.
2. As you are giving QueryString value as a parameter, so you should check if it exists or not before processing.
if(Request.QueryString["UserName"] != null && !string.IsNullOrEmpty(Request.QueryString["UserName"].ToString()))
{
}