473,322 Members | 1,755 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,322 software developers and data experts.

Executing command/instruction from a string variable

I need to execute the command/instruction which is stored in a
variable. ex

string str = "drRow["userid"].ToString()"

here i need execute the instruction stored in 'str' and get the value
from executing

drGalileoToday["userid"].ToString()

I have no idea as how this could be done. Please advise
Mar 27 '08 #1
2 1912
c# is not an interpreted language like javascript etc, so there is no easy
way to do this. In some cases you can use the compiler directly, but this is
not usually appropriate and there are security issues (that string could be
anything) - and scoping issues (how to supply drRow to an arbitrary block of
code).

In short - I don't think that this is the right approach to start with.
There may be more suitable approaches if you can tell us *why* you want to
do this. For example, if you just new "userid" and wanted to get the string
contents, then it would be trivial...

Marc
Mar 27 '08 #2
On Thu, 27 Mar 2008 02:50:01 -0700, Gancy <ga*****@gmail.comwrote:
sorry for multi posting. I wasn't sure if post was appropriate on
framework or language.
It was nominally related to either. The problem is that you posted your
message twice, rather than cross-posting (which is different from
multi-posting, what you did) it once to two different newsgroups. That
made it impossible for Jon to know, reading the framework newsgroup, that
the question had already been answered here in the C# newsgroup.

Pete
Mar 27 '08 #3

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

Similar topics

1
by: Falk Schneider | last post by:
I wrote a PHP shell script under Linux which puts all existing PS-Files within a directory into a list and should then start a single Ghostview window for each file. Sounds simple, but it's not: ...
0
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
1
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
12
by: curious1 | last post by:
Can someone tell me how the 'is' command works in relation to derived classes? For example - Class A {} Class B : A {} object o = new B(); if (o is A) {...}
7
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was...
2
by: vvenk | last post by:
Hello: I wrote a test procedure on Oracle that returns a string and a value. CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload ( P_ERROR OUT VARCHAR2, P_ERROR_NO ...
1
by: ryan1234 | last post by:
My ultimate goal is to get something like "ping.exe" to re-direct it's standardOutput in real time to an .aspx page. I've been able to get this behavior to work just fine in a regular console...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.