CREATE PROCEDURE dbo.sp_User_GetUser
(@dotnet.itags.org.strUser char(10), @dotnet.itags.org.strPass char(10))
AS
SELECT [UserID], [EmployeeID], [UserName], [RoleID], [Department], [Password], [Status] FROM [User]
WHERE [Password] = @dotnet.itags.org.strPass AND UserID=@dotnet.itags.org.strUser
So in my code as follows:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Session("strUser") = ""
Session("empID") = ""
Session("deptID") = ""
Session("currPeriod") = 0
Session("companyID") = ""
Session("facilityID") = ""
Session("Shift") = 0
Session("userName") = ""
Session("Role") = ""
End SubPrivate Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim dataReader As SqlDataReader
Dim strPass, strUser As String'Session("strUser") = txtUserID.Text
'SqlCommand1.Parameters("@dotnet.itags.org.pPass").Value = strPass
SqlCommand1.Parameters("@dotnet.itags.org.strUser").Value = strUser
SqlCommand1.Parameters("@dotnet.itags.org.strPass").Value = strPass'Opens the connection to the DB
SqlConnection2.Open()'Reads the data entered against DB records
dataReader = SqlCommand1.ExecuteReader()'If SqlCommand1.Parameters("@dotnet.itags.org.return_value").Value = 0 Then
' 'label display
' Return
'End IfSession("strUser") = strUser
Session("empID") = dataReader.GetString(1).ToString
Session("userName") = dataReader.GetString(2).ToString
Session("Role") = dataReader.GetString(3).ToString
Session("deptID") = dataReader.GetString(4).ToStringdataReader.Read()
Session("empID") = dataReader.GetString(1).ToString
dataReader.Close()
SqlCommand2.Parameters("@dotnet.itags.org.deptID").Value = Session("deptID")
dataReader = SqlCommand2.ExecuteReaderSession("companyID") = dataReader.GetString(0).ToString
Session("facilityID") = dataReader.GetString(1).ToString
Session("deptID") = dataReader.GetString(2).ToString
Session("Shift") = dataReader.GetString(3).ToString'SqlCommand2.Parameters("@dotnet.itags.org.empID").Value = Session("empID")
dataReader.Close()
dataReader.Read()Dim cmdPeriod As New SqlCommand("SELECT fn_getcurrentperiod('" & Session("companyID") & "','" & Session("facilityID") & "')", SqlConnection2)
Session("currPeriod") = cmdPeriod.ExecuteScalarResponse.Redirect("ReviewInterPersonal.aspx")
dataReader.Close()
'Closes Connection to DB
SqlConnection2.Close()
Any Ideas on what structure I need to redo or any help would be greatly appreciated.
Much Thanks,
JasonI think you better put the login information in a class, and store an object in the session, instead of so many.
Dim objUser as new User()
objUser.empID = dataReader.GetString(1).ToString();
objUser.userName = dataReader.GetString(2).ToString();
......
.........Session["User"] = objUser;
Just a suggestion.. :)
Due to me being a hardcore beginner I am not to familiar with doing it the way you explained. I have gotten past a point where I was getting an error, until I got a new Error! Fun stuff--Any help on what this is referring to would be much appreciated.
Procedure or function sp_Employees_GetSupervisorData has too many arguments specified.
Here is my code (By the way is this going to work with storing information from my SQL table in a Session Variable?) It stops where I placed the *******
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Session("User") = ""
Session("empID") = ""
Session("SuperEmpID") = ""
Session("deptID") = ""
Session("currPeriod") = 0
Session("companyID") = ""
Session("facilityID") = ""
Session("Shift") = 0
Session("userName") = ""
Session("Role") = ""
End SubPrivate Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim dataReader As SqlDataReader
Dim strPass, strUser As String'Session("strUser") = txtUserID.Text
strUser = txtUserID.Text
strPass = txtPassword.TextSqlCommand1.Parameters.Add(New SqlParameter("@.strUser", strUser))
SqlCommand1.Parameters.Add(New SqlParameter("@.strPass", strPass))'Opens the connection to the DB
SqlConnection2.Open()'Reads the data entered against SQL DB records
***** dataReader = SqlCommand1.ExecuteReader()********While dataReader.Read
Session("User") = strUser
Session("SuperEmpID") = dataReader.GetString(1).ToString
Session("userName") = dataReader.GetString(2).ToString
Session("Role") = dataReader.GetString(3).ToString
Session("deptID") = dataReader.GetString(4).ToString
End WhiledataReader.Close()
SqlCommand2.Parameters.Add(New SqlParameter("@.deptID", Session("deptID")))
dataReader = SqlCommand2.ExecuteReaderSession("companyID") = dataReader.GetString(0).ToString
Session("facilityID") = dataReader.GetString(1).ToString
Session("empID") = dataReader.GetString(3).ToString
Session("deptID") = dataReader.GetString(5).ToString
Session("Shift") = dataReader.GetString(7).ToStringdataReader.Close()
Dim cmdPeriod As New SqlCommand("SELECT fn_getcurrentperiod('" & Session("companyID") & "','" & Session("facilityID") & "')", SqlConnection2)
Session("currPeriod") = cmdPeriod.ExecuteScalarResponse.Redirect("ReviewInterPersonal.aspx")
dataReader.Close()'Closes Connection to DB
SqlConnection2.Close()
End Sub
much thanks,
jason
What alvinz is saying is make a class called objUser for instance then give that class several public properties, etc then in your main code can expose them and set them. Then save the class object. So instead of saying:
the car is red
the car has 4 cylnders
the car has 4 doors
these all belong to the car so you set them by car.color=red etc. Below is some beginning code to give you in an idea.
public class objUser
{
public int foo;
public objUser()
{
//
// TODO: Add constructor logic here
//
}
}
Then in your webform
private void Page_Load(object sender, System.EventArgs e)
{
objUser myUser = new objuser();
myUser.foo = 1;}
Then once you have set all the properties of your objUser class, put it in the session variable. Then when you get it back out you just read its properties again.
0 comments:
Post a Comment