473,729 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving table field name to variable name in VB.NET

Hello everyone, I am trying to move a field name to a variable in
vb.net. For example, first I retrieve the record from the database
and save its value:

....
userGroup =
ds.Tables("Defa ult").Rows(x).I tem("UserGroupA ccess").ToStrin g
'retrive access value from dataset
....

Then, depending on the value retrieved I want to setup a specific
boolean variable to True:

....
objUserAccess.[userGroup] = True
....

In this case the table might contain records such as this:

UserName Access
======== =======
Bob Admin
John User

And the objUserAccess contains variables such as this

admin as boolean
user as boolean

In the example above, if the value of the table field UserGroupAccess
is equal to Admin, then
it should basically set admin to true. If we were to manually do this
it would be set by this statement:

....
objUserAccess.A dmin = True
....

But instead of the above statement, It would be automated depending on
the value pulled from the database:

....
objUserAccess.[userGroup] = True
....

I would appreciate any help on finding the best way to accomplish
this.

Thanks Before Hand,
Adiel
Jun 27 '08 #1
3 2996
Looks like you are looking for properties (basically they seem to be a
"variable" but changing/reading the value runs some code to update/retrieve
this value).

Try http://msdn.microsoft.com/en-us/libr...77(VS.71).aspx

By using properties your class could load a user and make available several
boolean properties based on the underlying values read from the db...

I would also recommend reading the whole spec at least once so that you have
at least an overviw of what you have at your disposal...

--
Patrice

<ad*****@hotmai l.coma écrit dans le message de groupe de discussion :
b6************* *************** **...legroup s.com...
Hello everyone, I am trying to move a field name to a variable in
vb.net. For example, first I retrieve the record from the database
and save its value:

...
userGroup =
ds.Tables("Defa ult").Rows(x).I tem("UserGroupA ccess").ToStrin g
'retrive access value from dataset
...

Then, depending on the value retrieved I want to setup a specific
boolean variable to True:

...
objUserAccess.[userGroup] = True
...

In this case the table might contain records such as this:

UserName Access
======== =======
Bob Admin
John User

And the objUserAccess contains variables such as this

admin as boolean
user as boolean

In the example above, if the value of the table field UserGroupAccess
is equal to Admin, then
it should basically set admin to true. If we were to manually do this
it would be set by this statement:

...
objUserAccess.A dmin = True
...

But instead of the above statement, It would be automated depending on
the value pulled from the database:

...
objUserAccess.[userGroup] = True
...

I would appreciate any help on finding the best way to accomplish
this.

Thanks Before Hand,
Adiel

Jun 27 '08 #2
Patrice, thanks for your reply. Yes, I am familiar with properties
for classes. But, that is not what I am trying to accomplish. I have
a field in a table depending on the value of that field I am going to
set a specific boolean variable to True. Take a look at the following
table:

In this case the table might contain records such as this:
UserName Access
======== =======
Bob Admin
John User

The table contains the value of Admin for the user Bob. So if I run a
query against this table such as:

select * from tblUserAccess where UserName = 'Bob'

The values returned would be:

UserName UserGroupAccess
======== =======
Bob Admin

Now that I have this record, I extract the access level with the
following statement:

....
userGroup =
ds.Tables("Defa ult").Rows(0).I tem("UserGroupA ccess").ToStrin g
'retrive access value from dataset
....

Now the field name called userGroup contains the value "Admin"
Now I have a class called clsUserAccess as follows:

Public Class clsUserAccess
public Admin as boolean
public User as boolean
' for this example, the class uses two public variables with no
properties
End Class
Now comes my question, I want to move the table field name to a
variable name as follows:

' Instantiate the class
dim objUserAccess as new clsUserAccess
' Set the Admin variable to true
objUserAccess.[userGroup] = True ' <-- This is the statement I am
looking for, does it exist?
Of course the above statement does not exist but I am looking for its
equivalent. I am hoping to
find a way to do this instead of having to loop through each item such
as:

If userGroup = "Admin" then
objUserAccess.A dmin = True ' manually setting admin flag to true
elseif userGroup = "User" then
objUserAccess.U ser = True ' manually setting user flag to true
....
end if

Thanks Before Hand,
Adiel

Jun 27 '08 #3
Ah ok... This time I believe you are looking CallByName :
http://msdn.microsoft.com/fr-fr/libr...x6(VS.80).aspx
(which basically wraps capabilities found inside System.Reflecti on).
Hopefully I should have finally understood how you want to handle this...

--
Patrice
<ad*****@hotmai l.coma écrit dans le message de groupe de discussion :
db************* *************** **...legroups .com...
Patrice, thanks for your reply. Yes, I am familiar with properties
for classes. But, that is not what I am trying to accomplish. I have
a field in a table depending on the value of that field I am going to
set a specific boolean variable to True. Take a look at the following
table:

In this case the table might contain records such as this:
UserName Access
======== =======
Bob Admin
John User

The table contains the value of Admin for the user Bob. So if I run a
query against this table such as:

select * from tblUserAccess where UserName = 'Bob'

The values returned would be:

UserName UserGroupAccess
======== =======
Bob Admin

Now that I have this record, I extract the access level with the
following statement:

...
userGroup =
ds.Tables("Defa ult").Rows(0).I tem("UserGroupA ccess").ToStrin g
'retrive access value from dataset
...

Now the field name called userGroup contains the value "Admin"
Now I have a class called clsUserAccess as follows:

Public Class clsUserAccess
public Admin as boolean
public User as boolean
' for this example, the class uses two public variables with no
properties
End Class
Now comes my question, I want to move the table field name to a
variable name as follows:

' Instantiate the class
dim objUserAccess as new clsUserAccess
' Set the Admin variable to true
objUserAccess.[userGroup] = True ' <-- This is the statement I am
looking for, does it exist?
Of course the above statement does not exist but I am looking for its
equivalent. I am hoping to
find a way to do this instead of having to loop through each item such
as:

If userGroup = "Admin" then
objUserAccess.A dmin = True ' manually setting admin flag to true
elseif userGroup = "User" then
objUserAccess.U ser = True ' manually setting user flag to true
...
end if

Thanks Before Hand,
Adiel


Jun 27 '08 #4

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

Similar topics

16
3495
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record in a hidden field) I wish the user to be able to edit the data in the table, so I have extracted the records into hiddenfield, textareas, dropdown list and checkbox so that they can make changes. I named these elements as arrays and wish to run an...
5
14291
by: devx777 | last post by:
Hello, I am trying to find some information or an example on how to build a dynamic query in DB2 that would allow me to join a table which its name is stored as a field value on another table. I have done this in the past in SQL server, but DB2 is not as easy... Anyone out there that can help me? Your help will be much appreciated.
9
3253
by: john | last post by:
I have imported an Excel spreadsheet in Access. This table has 150 fields. The first field is 'user name', and all the other fields represent application names of which the value can be True of False for that particular user. User generally uses about 10 applications. I would like to divide this table into 3 tables: User, Application, and Relation User-Application. The user table is easy to make but how do I make the other two tables? If...
1
1583
by: SyddyS | last post by:
Hi all, please help ASAP! Well, it's been a long and bumpy ride, but my little Access DB is finally graduating and moving out of the house. My homebrewed contact and sales database is being taken over by the big leagues and converted by a pro company to a web-based SQL database- well outside my realm of abilities. I have one more duty to perform, then I'm out of the DB business for the forseeable future. Heres the basic structure...
11
3824
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result = mysql_query("select * from $tableInfo") ; for ($i = 0; $i < mysql_num_rows($result); $i++) {
3
2438
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of software test data. Each instance of a test is associated with a "test case", that is, a test item. Each test instance (or "run") may have a number of other characteristics too, such as browser used, OS (XP, Vista, Linux, Mac OSX, etc.), etc., but for...
5
2378
by: quirk | last post by:
I am trying to write a script where a page is populated with some maths questions, user answers them (it's timed but I've left this bit out), gets results on same page and ajax takes their score, sends it to php script which updates sql. Make sense so far?!! The problem I have is getting their score out of javascript and into ajax and therefore into the sql record table. I have no problem sending php variables to ajax, just the javascript...
0
1757
by: timber910 | last post by:
Ok, I have a button on a form that I'm using to create another table I will need later in my form. I have created a reference table called Ref_Table (holds my table names - using this as the tables with the orginal data changes from project to project), I have another reference table called Ref_Fields (this holds the fields I will need to pull out of the tables they are in.) I know there is a better way to code some of this so if you happen...
5
2113
by: timber910 | last post by:
I posted this in the VB forum but I think its in the wrong place. So I thought I would try here. _________________________________________ Ok, I have a button on a form that I'm using to create another table I will need later in my form. I have created a reference table called Ref_Table (holds my table names - using this as the tables with the orginal data changes from project to project), I have another reference table called Ref_Fields...
0
9280
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.