Hi all,
How to check the availability of name in login page?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Aug 11, 2011, 2:29 PM
If this post helps you mark it as answer
Thanks
Satyapriya NayakPosted Aug 10, 2011, 5:03 AM
Use the below code or run the attachment.
Program
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Pagetitle>
head>
<body>
<form id="form1" runat="server">
<div>
div>
<asp:Button ID="Button1" runat="server" Text="Availability of name from the database"
BackColor="#FF99FF" Font-Bold="True" Width="329px" /><br />
<asp:Label ID="Labelcheck" Text="Please enter any name to be verified from the database" runat="server" BackColor="#FFFF99"
Width="197px" ForeColor="#FF3300">asp:Label>
<asp:TextBox ID="txtUserName" runat="server" Width="197px">asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUserName" ErrorMessage="*Name Required">asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblMessage" runat="server" BackColor="#FF3300"
ForeColor="Black">asp:Label>
form>
body>
html>
Default.aspx.vb code
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim sqlda As SqlDataAdapter
Dim com As SqlCommand
Dim ds As DataSet
Dim str As String
Dim count As Integer
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
namecheck()
End Sub
Sub namecheck()
Dim con As New SqlConnection(strConnString)
con.Open()
str = "select count(*)from employee where ename='" & txtUserName.Text & "'"
com = New SqlCommand(str, con)
count = Convert.ToInt32(com.ExecuteScalar)
If count > 0 Then
lblMessage.Text = "Sorry! you can't take this username"
Else
lblMessage.Text = "You can take this username"
End If
End Sub
End Class