| Author |
Topic |
|
Mpilo
Yak Posting Veteran
52 Posts |
Posted - 2008-11-06 : 02:52:00
|
| Hi guys i looking for stored procedure that will allow the user to log in to a position the user is assigned to like:I have the structures Province,District and Branch.A user is assigned to one of this structure.and then if u a assigned to province i want a user tu see her province only and district that fall to that province |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-06 : 02:56:16
|
| pass user as a parameter and retrive only those Province or District or Branch for which he belongs from table. Show some sample data from table if you need more info. |
 |
|
|
Mpilo
Yak Posting Veteran
52 Posts |
Posted - 2008-11-06 : 03:11:28
|
Here is My user tableCreate Table Userr ( UserrNo int identity(020,1)Not Null, FirstName varchar(30), Surname varchar(30), IdNumber varchar(13), Province varchar(30), AssignTo varchar(30), OfficeName varchar(30), CellNumber int not null, Email varchar(30), R_Address varchar(100), R_Code int not null, UserName varchar(30), Passwordd int not null, Usertype varchar(30), DateCreated Datetime default getdate(), MembershipNo int Not Null, Constraint UserType_Pk Primary key clustered(UserrNo));My login ProcedureALTER procedure [dbo].[Logginde]@UserName varchar(100)='',@Password int=0AsSELECT UserName,Password,AssignTo,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,ProvinceFROM(SELECT Username AS UserName,Passwordd AS Password,AssignTo,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,ProvinceFROM UserrUNION ALLSELECT SurName,MembershipNum,Languages,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,TitleFROM Member)tWHERE UserName=@UserName and Password=@Passwordand Login procedure works like this:the user and member can login,if the user Login it first check where the user is assigned(Province,District,Branch) to and call that form my problem now is ,if the user is login with province i want the user to see only that province details,also in district here is my province tableCreate table Province( ProvinceNo int identity(001,1) Not Null, ProvinceName varchar (30), CityName varchar (30), LocationName varchar (30), Addresss varchar (100), TelephoneNo varchar (15), E_mail varchar (30), DateCreated Datetime default getdate(), Constraint Province_Pk Primary key clustered (ProvinceNo));------------------------------------------------------------------Create table District( DistrictNo int identity(0001,1) Not Null, DistrictName varchar(30), CityName varchar (30), LocationName varchar (30), Addresss varchar (100), TelephoneNo varchar (15), E_mail varchar (30), DateCreated Datetime default getdate(), ProvinceNo int Not Null, Constraint District_Pk Primary key clustered (DistrictNo));Alter table District with nocheck add Constraint District_Fk Foreign key (ProvinceNo) references Province (ProvinceNo) on delete cascadequote: Originally posted by visakh16 pass user as a parameter and retrive only those Province or District or Branch for which he belongs from table. Show some sample data from table if you need more info.
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-06 : 04:03:58
|
| [code]ALTER procedure [dbo].[Logginde]@UserName varchar(100)='',@Password int=0AsSELECT UserName,Password,AssignTo,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,p.ProvinceName,d.DistrictNameFROM(SELECT Username AS UserName,Passwordd AS Password,AssignTo,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,ProvinceFROM UserrUNION ALLSELECT SurName,MembershipNum,Languages,FirstName,IdNumber,R_Address,R_Code,CellNumber,E_mail,TitleFROM Member)tJOIN Province pON p.ProvinceName=t.ProvinceJOIN District dON d.ProvinceNo=p.ProvinceNoWHERE UserName=@UserName and Password=@Password[/code] |
 |
|
|
|
|
|