set class fields problem

G

Guest

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
 
G

Guest

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.ToString)
'Set databaseName in cConnection Class
cConnection.setDatabaseName(Me.txtAssistDatabaseName.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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top