C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Check Availability Of UserName


Posted Date: 17 Jun 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: Rumpa MMember Level: Gold    
Rating: Points: 10



 
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
reg.checkusername1 = TextBox1.Text;
int x = reg.checkavailability();
if (x == 1)
{
// ScriptManager.RegisterStartupScript(this, this.GetType(), "dg", "", false);
}
else
{
// ScriptManager.RegisterStartupScript(this, this.GetType(), "dg", "", false);
}
}
else
{
// ScriptManager.RegisterStartupScript(this, this.GetType(), "dg", "", false);
}
}


///////////////Class File////////////

public int checkavailability()
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlCommand cmd = new SqlCommand("checkavailability", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter();
param.Direction = ParameterDirection.ReturnValue;
param = cmd.Parameters.Add("@username", SqlDbType.VarChar, 100);
param.Direction = ParameterDirection.Input;
param.Value = checkusername;
param = cmd.Parameters.Add("@flag", SqlDbType.Int);
param.Direction = ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
return Convert.ToInt32(cmd.Parameters["@flag"].Value.ToString());
}

/////////Stored Procedure//////////////

ALTER PROCEDURE [dbo].[checkavailability]
@username varchar(100)
AS
BEGIN
declare @flag int
select @flag=count(*) from userregistration where username=@username
if(@flag<>0)
begin

return 1
end
else
begin
return 2
end
END




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Multiple Controls on single Event
Previous Resource: Split funtion
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use