TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yashu Shashi
1.5k
233
31.2k
username exist or not if exists choose differet name
Nov 1 2017 3:27 AM
How to check username exists or not in sqlserver databse while registering the user if alredy exists show message alredy exists choose different name without using stored procedure .
asps.cs
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace rummyRLodemo
{
public partial class registerex : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
SqlConnection con = new SqlConnection("Data Source=SHASHI\\SQLEXPRESS;Initial Catalog=Rummy;Integrated Security=True");
protected void btnRegister_Click(object sender, EventArgs e)
{
int userId = 0;
SqlCommand cmd = new SqlCommand();
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Parameters.AddWithValue("@Username", UserName.Text.Trim());
cmd.Parameters.AddWithValue("@Password", password.Text.Trim());
cmd.Parameters.AddWithValue("@Email", email.Text.Trim());
cmd.Connection = con;
con.Open();
userId = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
string message = string.Empty;
switch (userId)
{
case -1:
message = "Username already exists.\\nPlease choose a different username.";
break;
case -2:
message = "Supplied email address has already been used.";
break;
default:
message = "Registration successful.\\nUser Id: " + userId.ToString();
break;
}
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true);
}
}
}
Reply
Answers (
2
)
implement web crawler using Asp.net for extracting data.
Implementation of DHTMLX / DayPoilet or FullCalendar