HighTechTalks DotNet Forums  

set class fields problem

Dotnet General Discussions microsoft.public.dotnet.general


Discuss set class fields problem in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Koda
 
Posts: n/a

Default set class fields problem - 08-04-2005 , 07:00 AM






I have 2 classes (below). I am not able to set the fields in the User class
from the Connection class (marked 1 -5). No errors are thrown. I am
returning values from the db correctly because I can put them in variables
and display.

I hope I have explained my problem ok. What am I missing?

I am on 1.1 using VS.net 2003

Thanks for your help
Mike



'CODE
1) User - with these pertinent methods
Public Sub setUserRights(ByVal str As String)
userRights = str
End Sub
'/////////////////
Public Function getUserRights() As String
Return userRights
End Function

2)Connection -- with these pertinent methods

Imports BalanceOmatic.cUser
Dim cUser As New cUser


Public Sub getUserRightsFromDB(ByVal userlogin As String)
Dim SQL As String
Dim strUserRights As String
SQL = "Select ID, USER_ID, USER_NAME, USER_EMAIL, " & _
"USER_RIGHTS From TAB_USER_RIGHTS Where USER_LOGIN = '" & userlogin
& "'"

Try
Me.OraComm.CommandType = CommandType.Text
Me.OraComm.CommandText = SQL

Me.openDB()
Dim dr As OracleDataReader = Me.OraComm.ExecuteReader()
dr.Read()

1 cUser.setDbID(CType(dr.Item(0), Integer))
2 cUser.setUserID(CType(dr.Item(1), Integer))
3 cUser.setFullName(CType(dr.Item(2), String))
4 cUser.setEmailAddress(CType(dr.Item(3), String))
strUserRights = CType(dr.Item(4), String).ToString
Me.closeDB()
5 cUser.setUserRights(strUserRights)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Me.closeDB()
End Try
End Sub



Reply With Quote
  #2  
Old   
Koda
 
Posts: n/a

Default RE: set class fields problem - 08-04-2005 , 07:11 AM






I think the values may be getting set but I can't retrieve them to my form
class?


'Code from my form

Imports BalanceOmatic.cUser
Imports BalanceOmatic.cConnection

Dim cUser As New cUser 'provide reference for external object
Dim cConnection As New cConnection 'provide reference for external
object



Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
'Set login and password in cUser class
cUser.setLogin(Me.txtAssistUsername.Text.ToString)
cUser.setPassword(Me.txtAssistPassword.Text.ToStri ng)
'Set databaseName in cConnection Class
cConnection.setDatabaseName(Me.txtAssistDatabaseNa me.Text.ToString)
cConnection.setConnectionString(cUser.getLogin,
cConnection.getDatabaseName, cUser.getPassword)

cConnection.getUserRightsFromDB(cUser.getLogin)


******'This next line does not show the value
MsgBox(cUser.getdbID() & " dbID from cUser")











"Koda" wrote:

Quote:
I have 2 classes (below). I am not able to set the fields in the User class
from the Connection class (marked 1 -5). No errors are thrown. I am
returning values from the db correctly because I can put them in variables
and display.

I hope I have explained my problem ok. What am I missing?

I am on 1.1 using VS.net 2003

Thanks for your help
Mike



'CODE
1) User - with these pertinent methods
Public Sub setUserRights(ByVal str As String)
userRights = str
End Sub
'/////////////////
Public Function getUserRights() As String
Return userRights
End Function

2)Connection -- with these pertinent methods

Imports BalanceOmatic.cUser
Dim cUser As New cUser


Public Sub getUserRightsFromDB(ByVal userlogin As String)
Dim SQL As String
Dim strUserRights As String
SQL = "Select ID, USER_ID, USER_NAME, USER_EMAIL, " & _
"USER_RIGHTS From TAB_USER_RIGHTS Where USER_LOGIN = '" & userlogin
& "'"

Try
Me.OraComm.CommandType = CommandType.Text
Me.OraComm.CommandText = SQL

Me.openDB()
Dim dr As OracleDataReader = Me.OraComm.ExecuteReader()
dr.Read()

1 cUser.setDbID(CType(dr.Item(0), Integer))
2 cUser.setUserID(CType(dr.Item(1), Integer))
3 cUser.setFullName(CType(dr.Item(2), String))
4 cUser.setEmailAddress(CType(dr.Item(3), String))
strUserRights = CType(dr.Item(4), String).ToString
Me.closeDB()
5 cUser.setUserRights(strUserRights)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Me.closeDB()
End Try
End Sub



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.