String qryChkExist = "SELECT isnull(column_name,'') as Article_alias from Table_Name where column_name='" + txtalias.text.tostring().trim()+ "'";
String ChkRecord = (String)SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, qryChkExist);
if (ChkRecord != null)
{
if (ChkRecord != "")
{
lblMsg.Text = "Another Alias with this Name already exists. Please choose another Alias.";
return;
}
}
ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language.
Thursday, May 31, 2012
Monday, May 21, 2012
Limitation Login
Step 1:Use NameSpaces As
using System.Data.SqlClient;
Step 2: Global Declaration Are:
SqlConnection con = new SqlConnection("Ur Connection");
Step 3:Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.ViewState["count"] = 0;
}
}
Step 4:write a Method
public void m()
{
string user = "";
string pass = "";
string str = "select * from tbl_Login where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";
//string count = "";
con.Open();
SqlCommand cmd = new SqlCommand(str, con);
cmd.CommandType = CommandType.Text;
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read() == true)
{
user = dr[1].ToString();
pass = dr[2].ToString();
}
dr.Close();
if (TextBox1.Text == user && TextBox2.Text == pass)
{
Response.Redirect("Default2.aspx");
}
else
{
Label1.Text = "Login Failed";
}
con.Close();
Step 5: On Button Click
protected void Button1_Click(object sender, EventArgs e)
{
int i = Convert.ToInt32 (this.ViewState["count"].ToString())+1;
//int i = this.ViewState["count"] + 1;
this.ViewState["count"]=i;
if (i <=3)
{
m();
}
else
{
Label1.Text = "Please Contact Admin.. YOuR Login Limit Exceed";
}
}
using System.Data.SqlClient;
Step 2: Global Declaration Are:
SqlConnection con = new SqlConnection("Ur Connection");
Step 3:Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.ViewState["count"] = 0;
}
}
Step 4:write a Method
public void m()
{
string user = "";
string pass = "";
string str = "select * from tbl_Login where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";
//string count = "";
con.Open();
SqlCommand cmd = new SqlCommand(str, con);
cmd.CommandType = CommandType.Text;
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read() == true)
{
user = dr[1].ToString();
pass = dr[2].ToString();
}
dr.Close();
if (TextBox1.Text == user && TextBox2.Text == pass)
{
Response.Redirect("Default2.aspx");
}
else
{
Label1.Text = "Login Failed";
}
con.Close();
Step 5: On Button Click
protected void Button1_Click(object sender, EventArgs e)
{
int i = Convert.ToInt32 (this.ViewState["count"].ToString())+1;
//int i = this.ViewState["count"] + 1;
this.ViewState["count"]=i;
if (i <=3)
{
m();
}
else
{
Label1.Text = "Please Contact Admin.. YOuR Login Limit Exceed";
}
}
Labels:
Sql
except keyword in sql server
CREATE TABLE EMP (ID INTEGER NOT NULL,NAME VARCHAR(20) NOT NULL, CITY VARCHAR(20) NULL)
insert into EMP values(1, 'EMP1', 'DELHI')
insert into EMP values(2, 'EMP2', 'CHENNAI')
insert into EMP values(3, 'EMP3', 'PUNE')
insert into EMP values(4, 'EMP4', 'AGRA')
insert into EMP values(5, 'EMP5', 'CHENNAI')
CREATE TABLE CITY(ID INT IDENTITY, CITY_NAME VARCHAR(20))
insert into CITY values('CHENNAI')
SELECT CITY FROM EMP EXCEPT SELECT CITY_NAME FROM CITY
insert into EMP values(1, 'EMP1', 'DELHI')
insert into EMP values(2, 'EMP2', 'CHENNAI')
insert into EMP values(3, 'EMP3', 'PUNE')
insert into EMP values(4, 'EMP4', 'AGRA')
insert into EMP values(5, 'EMP5', 'CHENNAI')
CREATE TABLE CITY(ID INT IDENTITY, CITY_NAME VARCHAR(20))
insert into CITY values('CHENNAI')
SELECT CITY FROM EMP EXCEPT SELECT CITY_NAME FROM CITY
Labels:
Sql
Tuesday, May 1, 2012
insert record in two table
create table Person ( p_id int IDENTITY(1,1) not null primary key, Fname varchar(50), Lname varchar(50), address varchar(50) ) go create table orders ( o_id int IDENTITY(1,1) not null primary key, oname varchar(50), Qty int, p_id int foreign key references Person(p_id), prize Int ) go Create Proc Usp_Orders_Insert ( @Param_Fname Varchar(50), @Param_Lname Varchar(50), @Param_Address Varchar(50), @Param_oname Varchar(50), @Param_Qty Int, @Param_prize Int ) As Begin Set Nocount On Declare @PersonID Int Begin Try Begin Tran Insert Person(Fname, Lname, [address]) Values(@Param_Fname, @Param_Lname, @Param_Address) Select @PersonID = @@Identity Insert orders(oname, Qty, p_id, prize) Values(@Param_oname, @Param_Qty, @PersonID, @Param_prize) Commit End Try Begin Catch Declare @Message Varchar(Max) Select @Message = 'Error : ' + ERROR_MESSAGE() + CHAR(10) + 'Line No: '+ Cast(ERROR_LINE() as Varchar(10)) Raiserror(@Message,16,1) Rollback End Catch End Go
Labels:
Sql
Subscribe to:
Posts (Atom)