Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute command saved in variable...

Status
Not open for further replies.

lidds

Programmer
Jun 9, 2005
72
GB
I don't know if this is possible, but what I want to have is a SQL table that contains has one column called "Command" that contains a VB.Net code E.g.

Me.btnHome.Enabled = False
Me.btnSave.Enabled = True

What I then want to do is query the database, and then loop through the datareader and execute each command. I am able to do the SQL call and datareader stuff, however I am not sure how to execute the VB.Net command held in the variable / datareader

Thanks

Simon
 
Do you want to keep just Enable property of a control?

If so, you can keep in your table:

[pre]
MyControl MyEnable
btnHome 0
btnSave 1
[/pre]

and you can use it by:

Code:
While dtReader.Read = True
  Me.Controls(dtReader.Item("MyControl")).Enable = dtReader.Item("MyEnable")
End While

Have fun.

---- Andy
 
My preferred approach would be very similar to that suggested by Andrzejek, however what you want is very straightforward.

I've used an approach similar to this on several occasions: Using In Line Compilation.

Or you could use VB.Net scripting see: Scripting using .Net

You will find that there are several variations of the above two solutions on Code Project, I've just linked the first of each type that I found.

By the way, some of these examples are written in C# - you don't need to worry about converting them to VB, just create them as dlls and reference them in your program.

But as I said earlier, unless you have a good reason to use something similar to either the second or third option, I would use the first option.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top