ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.How to check if user in user account table is opposite FriendUserName column in USERFollow table<p>Hi micah,</p> <p>I have created sample. You need to change as per your requirement.</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:Label ID=&#34;lblMerged&#34; Text=&#34;Merged&#34; runat=&#34;server&#34; Visible=&#34;false&#34; /&gt; &lt;asp:Label ID=&#34;lblNotMerged&#34; Text=&#34;NotMerged&#34; runat=&#34;server&#34; Visible=&#34;false&#34; /&gt; &lt;asp:Label ID=&#34;lblUserNotValid&#34; Text=&#34;User Not Valid&#34; runat=&#34;server&#34; Visible=&#34;false&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;">Code</span></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString[&#34;UserName&#34;] != null) { if (!IsPostBack) { DataTable dt = GetData(Request.QueryString[&#34;UserName&#34;]); if (dt.Rows.Count &gt; 0) { string FriendUserName = string.Empty; string userName = dt.Rows[0][&#34;UserName&#34;].ToString().ToLower(); if (userName != &#34;user not valid&#34;) { FriendUserName = dt.Rows[0][&#34;FriendUserName&#34;].ToString().ToLower(); if (userName != FriendUserName) { lblMerged.Visible = true; } else { lblNotMerged.Visible = true; } } else { lblUserNotValid.Visible = true; } } } } } private DataTable GetData(string userName) { DataTable dt = new DataTable(); string constr = ConfigurationManager.ConnectionStrings[1].ConnectionString; string query = &#34;Getbuttons&#34;; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(query, con)) { con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(&#34;@UserName&#34;, userName); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { sda.Fill(dt); } con.Close(); } } return dt; }</pre> <p><span style="text-decoration: underline;">SQL</span></p> <pre class="brush: sql">CREATE PROC Getbuttons @UserName VARCHAR(50) AS BEGIN IF EXISTS(SELECT UserName FROM User3 WHERE UserName = @UserName) BEGIN SELECT UserName,FriendUserName FROM UserFollow WHERE UserName = @UserName OR FriendUserName = @UserName END ELSE BEGIN SELECT &#39;User not valid&#39; AS UserName END END --EXEC Getbuttons &#39;Steve1&#39;</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/404479/How-to-check-if-user-in-user-account-table-is-opposite-FriendUserName-column-in-USERFollow-table/https://www.aspforums.net:443/Threads/404479/How-to-check-if-user-in-user-account-table-is-opposite-FriendUserName-column-in-USERFollow-table/Wed, 27 Apr 2016 09:29:31 GMT