|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
||||
|
||||
|
Boolean question.
Hi I'm very very new with VB and I have some questions, and I need your help guys, so if anyone can help me
thanks.Well, I'm working with an SQL DB, and I'm working on ASP.net. so UI have decided to use storedprodures for my web application. well, my question is as follow: First I have this Procedure on my SQL DB: CREATE PROCEDURE CustomerLogin ( @strLogin nvarchar(50), @strPassword nvarchar(50), @strCustomerID nvarchar(50) OUTPUT, @boolActiveUser bit OUTPUT ) AS SELECT @strCustomerID = strCustomerID, @boolActiveUser = boolActiveUser FROM tblUsers WHERE strLogin = @strLogin AND strPassword = @strPassword IF @@Rowcount < 1 SELECT @strCustomerID = 0 GO where boolActiveUser is to chech if the user is authorized to enter the site or not. so now, I'm creating this function to retrieve these 2 values (CustomerID and BoolActiveUser) Public Function Login(ByVal strLogin As String, ByVal strPassword As String) As String Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("CustomerLogin", myConnection) myCommand.CommandType = CommandType.StoredProcedure Dim parameterstrLogin As SqlParameter = New SqlParameter("@strLogin", SqlDbType.NVarChar, 50) parameterstrLogin.Value = Cstr(strLogin) myCommand.Parameters.Add(parameterstrLogin) Dim parameterstrPassword As SqlParameter = New SqlParameter("@strPassword", SqlDbType.NVarChar, 50) parameterstrPassword.Value = Cstr(strPassword) myCommand.Parameters.Add(parameterstrPassword) Dim parameterstrCustomerID As SqlParameter = New SqlParameter("@strCustomerID", SqlDbType.NVarChar, 50) parameterstrCustomerID.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterstrCustomerID) Dim parameterboolActiveUser AS SqlParameter = New SqlParameter("@boolActiveUser", SqlDBType.Bit, 1) parameterboolActiveUser.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterboolActiveUser) myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close() Dim strCustomerID As String = Cstr(parameterstrCustomerID.Value) Dim boolActiveUser As Boolean = (parameterboolActiveUser.Value) If strCustomerID = 0 Then Return nothing Else Return strCustomerID.ToString() Return boolActiveUser.Boolean() End If End Function My question is if it is right what I have written in red, and one more thing is how can I request this values from my aspx pages?. |
|
#2
|
||||
|
||||
|
I realized that I have been doing a terrible error:
so I fixed my code, but still I need to know about the boolean, if I'm retrieving it right?, if I'm passing it right?, and how I should retrieve this values from my aspx.... as boolean or string. thanks. Jessica Public Function Login(ByVal strLogin As String, ByVal strPassword As String) As LoginDetails Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("CustomerLogin", myConnection) myCommand.CommandType = CommandType.StoredProcedure Dim parameterstrLogin As SqlParameter = New SqlParameter("@strLogin", SqlDbType.NVarChar, 50) parameterstrLogin.Value = Cstr(strLogin) myCommand.Parameters.Add(parameterstrLogin) Dim parameterstrPassword As SqlParameter = New SqlParameter("@strPassword", SqlDbType.NVarChar, 50) parameterstrPassword.Value = Cstr(strPassword) myCommand.Parameters.Add(parameterstrPassword) Dim parameterstrCustomerID As SqlParameter = New SqlParameter("@strCustomerID", SqlDbType.NVarChar, 50) parameterstrCustomerID.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterstrCustomerID) Dim parameterboolActiveUser AS SqlParameter = New SqlParameter("@boolActiveUser", SqlDBType.Bit, 1) parameterboolActiveUser.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterboolActiveUser) myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close() Dim myLoginDetails As LoginDetails = New LoginDetails () myLoginDetails.strCustomerID = Cstr(parameterstrCustomerID.Value) myLoginDetails.boolActiveUser = (parameterboolActiveUser.Value) End Function Public Class LoginDetails Public strCustomerID As String Public boolActiveUser As String End Class |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Boolean question. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|