| Author: Shankar Suresh 01 Oct 2008 | Member Level: Gold | Rating:  Points: 2 |
you have to check if exist condition in your query........ to try like this sp........
Create Proc SPR_Bankmaster_Save @BankID nvarchar(50), @BankName nvarchar(50) as if exists(select BankID from tbl_Bankmaster where BankID=@BankID) return 1 else insert into tbl_Bankmaster ( BankID, BankName ) values ( @BankID, @BankName )
GO
|
| Author: Prafulla S Shimpi 01 Oct 2008 | Member Level: Gold | Rating:     Points: 15 |
Subhishini,
first of all, no need to say sorry. everybody post here to get answer for their queries and site is dedicated to share the knowledge and find the solutions to their problem.
Now, answer to you queston:
1. UserName must be unique (probably PRIMARY Key field in database) 2. when user enters his details (at the time of sign up) i.e. on click of CreateUser Button click, you need to check whethher any user with this username already exists in database or not? If not, then allow to create new record, otherwise show an alert to the user 'UserName already exits' . Password could be same for two different user, you should not restrict the user for the same.
You can write the a small function to check whether UserName is already exists or Not.
If this function returns TRUE, then show alert and stop there, otherwise go ahead with Creating new User.
Private Function FnCheckUserExists(ByVal strUserName As String) As Boolean Try
string strConn= //write the connectionstring string strSQL = "Select * from UserMaint where UserName = ' " & strUserName & "'"; SqlConnection gConn = new SqlConnection(strConn);
SqlDataReader sReader;
using (sReader = new SqlCommand(strSQL , gConn).ExecuteReader ()) { if (sRader.HasRows) Return TRUE; else Return FALSE;
} Catch ex As Exception //Handle exception End Try
End Function
Hope this will help
|
| Author: subhashini 01 Oct 2008 | Member Level: Bronze | Rating: Points: 1 |
thank you
|