| Author: Reddy 26 Aug 2008 | Member Level: Silver | Rating:  Points: 1 |
It means u have the column of the email in ur table(database)
|
| Author: rajitha 26 Aug 2008 | Member Level: Silver | Rating:  Points: 6 |
hai,i think you are asking about check availability right?
write this stored procedure for this one:
CREATE PROCEDURE pro_registration
@dname VARCHAR(50), @emailid VARCHAR(50), @pwd VARCHAR(50)
AS declare @temp int BEGIN
select @temp = max(userid) from tbl_registration
if(@temp is null) set @temp=1 else set @temp=@temp+1
INSERT INTO tbl_registration(userid,displayname,Emailid,password) VALUES(@temp,@dname,@emailid,@pwd) insert into tb_login(username,password) values(@emailid,@pwd) END GO
call this stored procedure in front end: ok
protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("initial catalog=rajitha;data source=sys01;user id=sa"); con.Open(); string str = "select Emailid from tbl_registration where Emailid='" + TextBox3.Text + "'"; SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = con; cmd1.CommandText = str; cmd1.CommandType = CommandType.Text; // cmd1.Parameters.Add("@eid", System.Data.SqlDbType.VarChar).Value = TextBox3.Text.ToString(); SqlDataReader dr = cmd1.ExecuteReader(); string uname = TextBox3.Text; if(dr.Read()) { if (uname == dr["Emailid"].ToString())
// Session["Emailid"] = TextBox3.Text; Response.Write("username already exists"); return; //cmd1.ExecuteReader(); } else { SqlConnection conn = new SqlConnection("initial catalog=rajitha;data source=sys01;user id=sa"); conn.Open(); SqlCommand cmd = null; using (conn) { using (cmd = new SqlCommand()) { // cmd.CommandType = System.Data.CommandType.Text; string storedprocedure = "pro_registration"; // string str = "FORUMS_LOGINREGISTRATION"; cmd.Connection = conn; cmd.CommandText = storedprocedure; cmd.CommandType = CommandType.StoredProcedure;
//"INSERT INTO tb_registration(userid,displayname,Emailid,passwor d) VALUES (@temp,@dname,@emailid,@pwd)"; try { cmd.Parameters.Add("@dname", System.Data.SqlDbType.VarChar, 50).Value = TextBox1.Text.ToString(); cmd.Parameters.Add("@emailid", System.Data.SqlDbType.VarChar, 50).Value = TextBox3.Text.ToString(); cmd.Parameters.Add("@pwd", System.Data.SqlDbType.VarChar, 50).Value = TextBox4.Text.ToString(); cmd.ExecuteScalar(); } catch (Exception ex) { throw ex; } finally { cmd.Dispose(); conn.Close(); } }
}
Server.Transfer("Default4.aspx"); }
con.Close(); } this is for inserting data into database whatever you entered in your textboxes and also for checking whether the user is already exists or not.
hope this will help for you
|
| Author: rajitha 26 Aug 2008 | Member Level: Silver | Rating:  Points: 6 |
hai,i think you are asking about check availability right?
write this stored procedure for this one:
CREATE PROCEDURE pro_registration
@dname VARCHAR(50), @emailid VARCHAR(50), @pwd VARCHAR(50)
AS declare @temp int BEGIN
select @temp = max(userid) from tbl_registration
if(@temp is null) set @temp=1 else set @temp=@temp+1
INSERT INTO tbl_registration(userid,displayname,Emailid,password) VALUES(@temp,@dname,@emailid,@pwd) insert into tb_login(username,password) values(@emailid,@pwd) END GO
call this stored procedure in front end: ok
protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("initial catalog=rajitha;data source=sys01;user id=sa"); con.Open(); string str = "select Emailid from tbl_registration where Emailid='" + TextBox3.Text + "'"; SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = con; cmd1.CommandText = str; cmd1.CommandType = CommandType.Text; // cmd1.Parameters.Add("@eid", System.Data.SqlDbType.VarChar).Value = TextBox3.Text.ToString(); SqlDataReader dr = cmd1.ExecuteReader(); string uname = TextBox3.Text; if(dr.Read()) { if (uname == dr["Emailid"].ToString())
// Session["Emailid"] = TextBox3.Text; Response.Write("username already exists"); return; //cmd1.ExecuteReader(); } else { SqlConnection conn = new SqlConnection("initial catalog=rajitha;data source=sys01;user id=sa"); conn.Open(); SqlCommand cmd = null; using (conn) { using (cmd = new SqlCommand()) { // cmd.CommandType = System.Data.CommandType.Text; string storedprocedure = "pro_registration"; // string str = "FORUMS_LOGINREGISTRATION"; cmd.Connection = conn; cmd.CommandText = storedprocedure; cmd.CommandType = CommandType.StoredProcedure;
//"INSERT INTO tb_registration(userid,displayname,Emailid,passwor d) VALUES (@temp,@dname,@emailid,@pwd)"; try { cmd.Parameters.Add("@dname", System.Data.SqlDbType.VarChar, 50).Value = TextBox1.Text.ToString(); cmd.Parameters.Add("@emailid", System.Data.SqlDbType.VarChar, 50).Value = TextBox3.Text.ToString(); cmd.Parameters.Add("@pwd", System.Data.SqlDbType.VarChar, 50).Value = TextBox4.Text.ToString(); cmd.ExecuteScalar(); } catch (Exception ex) { throw ex; } finally { cmd.Dispose(); conn.Close(); } }
}
Server.Transfer("Default4.aspx"); }
con.Close(); } this is for inserting data into database whatever you entered in your textboxes and also for checking whether the user is already exists or not.
hope this will help for you
|
| Author: venkatesan 26 Aug 2008 | Member Level: Diamond | Rating:  Points: 1 |
Hi
wat is the use of Temp
wat u are going to do using temp..
let u clearly explain..
Regards, M.Venkatesan. Dot Net Code Snippets
|
| Author: venkatesan 26 Aug 2008 | Member Level: Diamond | Rating:  Points: 4 |
I think u create the stored procedure
if there is no record assigning userid=1 else
increment the userid from the Max(userid)
BUT My Requirement is If the email typed by the user
is exist or not .. ie Going to check in the Stored procedure itself..?
Regards, M.Venkatesan. Dot Net Code Snippets
|
| Author: rajitha 26 Aug 2008 | Member Level: Silver | Rating:  Points: 6 |
check this one
CREATE PROCEDURE FORUMS_LOGINREGISTRATION @PV_DISPLAYNAME VARCHAR(50), @PV_EMAILID VARCHAR(50), @PV_PASSWORD VARCHAR(50) AS BEGIN
DECLARE @LV_USERID INT
IF EXISTS(SELECT EMAILID FROM TBL_REGISTRATION WHERE EMAILID=@PV_EMAILID) BEGIN
SELECT '0' END ELSE BEGIN BEGIN TRAN INSERT INTO TB_LOGIN(USERNAME,PASSWORD)VALUES(@PV_EMAILID,@PV_PASSWORD)
IF(@@ERROR!=0) GOTO ERRHANDLER
SET @LV_USERID=SCOPE_IDENTITY()
INSERT INTO TBL_REGISTRATION(USERID,DISPLAYNAME) VALUES(@LV_USERID,@PV_DISPLAYNAME)
IF(@@ERROR!=0) GOTO ERRHANDLER
ELSE BEGIN COMMIT TRAN SELECT @LV_USERID END
END
ERRHANDLER: ROLLBACK TRAN RETURN
END GO
this will help you ok
|