SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old August 12th, 2004, 03:35 PM
jessie2477's Avatar
jessie2477 jessie2477 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 293 jessie2477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 13 h 29 m 5 sec
Reputation Power: 4
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?.

Reply With Quote
  #2  
Old August 12th, 2004, 04:03 PM
jessie2477's Avatar
jessie2477 jessie2477 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 293 jessie2477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 13 h 29 m 5 sec
Reputation Power: 4
Red face

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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Boolean question.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway