Note that there are some explanatory texts on larger screens.

plurals
  1. POInstant Username check availablity with database using asp.net
    primarykey
    data
    text
    <p>I am trying to use one of the best example for checking the username availability from the below site <a href="http://www.highoncoding.com/Articles/439_Performing_Instant_UserName_Availability_Check_Using_JQuery_Ajax_API.aspx" rel="nofollow">http://www.highoncoding.com/Articles/439_Performing_Instant_UserName_Availability_Check_Using_JQuery_Ajax_API.aspx</a></p> <p>And It's just verifying with some pre-initiated names but I wan't to try with my database can anyone suggest me how to proceed further.</p> <p>Here is the code:</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; var userName = ''; $(document).ready(function() { $("#txtUserName").blur(function() { userName = $(this).val(); if(userName.length &lt;= 6) { $("#display").text("username must be atleast 7 characters"); $("#display").css("background-color","red"); } else { $.ajax( { type:"POST", url:"AjaxService.asmx/CheckUserNameAvailability", data:"{\"userName\":\"" + userName + "\"}", dataType:"json", contentType:"application/json", success: function(response) { if(response.d == true) { $("#display").text("username is available"); $("#display").css("background-color","lightgreen"); } else { $("#display").text("username is already taken"); $("#display").css("background-color","red"); } } }); } }); }); &lt;/script&gt; </code></pre> <p>This AjaxService.asmx:</p> <pre><code>Imports System.Collections Imports System.ComponentModel Imports System.Data Imports System.Linq Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Xml.Linq Imports System.Collections.Generic Namespace JQueryUserNameAvailability &lt;WebService([Namespace] := "http://tempuri.org/")&gt; _ &lt;WebServiceBinding(ConformsTo := WsiProfiles.BasicProfile1_1)&gt; _ &lt;ToolboxItem(False)&gt; _ &lt;System.Web.Script.Services.ScriptService&gt; _ Public Class AjaxService Inherits System.Web.Services.WebService &lt;WebMethod&gt; _ Public Function CheckUserNameAvailability(userName As String) As Boolean Dim userNames As List(Of [String]) = New List(Of String)() From { _ "azamsharp", _ "johndoe", _ "marykate", _ "alexlowe", _ "scottgu" _ } Dim user = (From u In userNames Where u.ToLower().Equals(userName.ToLower())u).SingleOrDefault(Of [String])() Return If([String].IsNullOrEmpty(user), True, False) End Function End Class End Namespace </code></pre> <p>Modified code:</p> <pre><code> Public Function CheckUserNameAvailability(ByVal userName As String) As Boolean Dim strSql As String = String.Format("SELECT COUNT(UserNameCol) FROM Registration WHERE UserNameCol = '{0}'", userName) Dim strConnection As String = "Data Source=.\sqlexpress;Initial Catalog=Users;Integrated Security=True" Dim sqlConn As New SqlConnection(strConnection) Dim sqlDataAdap As New SqlDataAdapter(strSql, sqlConn) Dim dt As New DataTable() sqlDataAdap.Fill(dt) If Convert.ToInt32(dt.Rows(0)(0)) &gt; 0 Then Return False End If Return True End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload