title: Get Data from Database Where UserID is equal to value from asp:label
body: <p>Hello and Thanks for reading.</p>
  
  <p>I have a form where users can Insert data into my database and at the same time, The users unique ID is store in the same table.</p>
  
  <p>Here is the Code where I store the Unique in a label:</p>
  
  <pre><code>MembershipUser user = Membership.GetUser();
  string id = user.ProviderUserKey.ToString();
  lblID.Text = id.ToString();
  </code></pre>
  
  <p>This is how my Database looks like / ID, Name, Email, Subject, Message, UserID / </p>
  
  <p>Here is my Insert to Database Code:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
      conn.Open();
  
      string Name = txtName.Text;
      string Email = txtEmail.Text;
      string Subject = ddlSubject.SelectedValue;
      string Message = txtMessage.Text;
      string UniqueID = lblID.Text;
  
      string query = "INSERT INTO Ticket(Name, Email, Subject, Message, UserID)" + "Values('" + Name + "', '" + Email + "', '" + Subject + "', '" + Message + "', '" + UniqueID + "')";
      using (SqlCommand com = new SqlCommand(query, conn))
      {
          com.ExecuteNonQuery();
      }
  </code></pre>
  
  <p>What I'm having problems with is to Get data from the database where UserID = lblID.text.</p>
  
  <p>as you can see in the code below I'm having a problem finding out what to write to load the data, where UserID = lblID.text.</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
                  conn.Open();
  
                  using (var GetName = new SqlCommand("SELECT Name FROM Ticket WHERE UserID=''", conn))
                  using (SqlDataReader dr = GetName.ExecuteReader())
                  {
                      if (dr.Read())
                      {
                          lblGetData.Text = dr.GetString(dr.GetOrdinal("Name"));
                      }
                  }
  </code></pre>
  
  <p>Thanks alot for your help.</p>