473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

set class fields problem

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
Aug 4 '05 #1
1 1195
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:
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

Aug 4 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthias Kaeppler | last post by:
Sorry if this has been discussed before (I'm almost certain it has), but I didn't know what to google for. My problem is, I have a class, a gtkmm widget, and I want it to serve as a base class...
3
by: J E E | last post by:
Hi! Is it possible to access fields in a derived class using reflection? Code below works fine when I access it as a private member in the Page class, but not when accessing base class member...
3
by: J.J. Feminella | last post by:
(Please disregard the previous message; I accidentally sent it before it was completed.) I have source code similar to the following. public class Vehicle { protected string dataV; // ......
9
by: Richard Brown | last post by:
Can anyone give me a good argument one way or another? I have an 'address' set of fields that are used in various situations (a client has an address, a destination has an address, etc). These...
16
by: Richard Brown | last post by:
Ok, now I am truely going nuts... probably why I didn't use the Class Builder in VB6 extensively. But, being the 'proper programmer' that I should, I'm trying to bite the bullet and build...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
3
by: eBob.com | last post by:
I have several applications which mine web sites for personal information which they publish. They publish the info in one form, I transform the info into Excel spreadsheets. So all these...
0
by: Don Leckie | last post by:
Hi, I hope someone can really help me. This problem has me stumped. I have class "A" that does not implement Serializable, but class "A" subclasses Serializable class "B". Therefore, when...
2
by: mgoold2002 | last post by:
Hello. I've just begun programming in VB .NET, and I'm trying to turn all my modules into classes. In order to retrieve/exchange values from one class to another, I initiated New instances of the...
6
by: MattWilson.6185 | last post by:
Hi, I'm trying to find out if something is possible, I have a few diffrent lists that I add objects to and I would like to be able to have a wrapper class that won't affect the internal object, for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.