1. How to check UserId available in database or not ?
A : First design the page like
A : First design the page like
Source Page,
Code behind,
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from test where testid=" + TextBox1.Text.Trim(), con);
int i = Convert.ToInt32(cmd.ExecuteScalar());
if (i > 0)
{
Label3.Text = "This UserId is already existed";
}
else
{
Label3.Text = "This User Id not existed";
}
}
------------------------------------------------------------------------
2. How to find the last 2 characters in a given input string
Code behind,
string str=txtinput.Text.Trim().Substring(Math.Max(0,txtinput.Text.Trim().Length-2));
---------------------------------------------------------------------------------
No comments:
Post a Comment