473,396 Members | 2,004 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,396 software developers and data experts.

Fieldname refelection

Hi,

I am trying to find a way of accessing a custom attribute defined on a field
from the actual field reference as opposed to the symbolic name of the
field. As that probably doesn't make sense I will show what I am trying to
do:

class SomeDatabaseObject : DatabaseObject
{
void Query()
{
......
BindParameter(id, sqlCommand);
......
}
[DatabaseAttribute("id", "@id", System.Data.SqlDbType.Int,
AttributeType.Key, 4)]
private int id;
}
The class DatabaseObject defines a BindParameter() method that will create
the binding and set the value in the SqlCommand object using the information
defined on the custom attribute class DatabaseAttributeAttribute. This way
if the DBA goes and changes the name of the column or SP parameter name I
can just update the DatabaseAttribute attribute on id.
My problem is in the implementation of BindParameter(object obj, SqlCommand
sqlComm) I need to be able to retrieve the custom attribute on the id field,
but I can only find a way of doing this symbolically, which is what I am
trying to avoid. I could add another parameter to the DatabaseAttribute
which is the symbolic name and change the BindParameter signature to
BindParameter(string fieldName, SqlCommand sqlComm) calling it via:

BindParameter("id", id, sqlCommand);

instead, this seems redundant and errors cannot be caught at compile time.

Any ideas would be appreciated.

Cheers,
Nic
Nov 16 '05 #1
1 1266
I am trying to find a way of accessing a custom attribute defined on a field
from the actual field reference as opposed to the symbolic name of the
field.


You can't do that. What's passed to the BindParameter method is the
value of the field variable, not a "reference" to the field itself.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

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

Similar topics

6
by: Margaret MacDonald | last post by:
It appears that the 'table.field' dot notation is not preserved by php's mysql library. I can create some join 'SELECT a.id, b.id FROM table1 AS a, table2 AS b' but when I try to refer to the...
4
by: MARTIN DAVIES | last post by:
I hope you can help. My Linux MYSQL 3.23.52 database server is working OK generally. However, in a database I have a field name that ends with a # (hash UK as opposed to £ which is a pound UK)...
3
by: Sagaert Johan | last post by:
The update seems to fail becorse of the fieldname in my DB One of the fields is called "Zone" in my MDB If i change the fieldname in both the database and in my test application, the error is...
1
by: ad | last post by:
Hi, What is the difference between (string)dr and dr.ToString();
1
by: Abe Simpson | last post by:
Hi all, My form file has this attribute: <META http-equiv="Content-Type" content="text/html; charset=utf-8"> The form's action points to an .aspx file where I try to retrieve field values...
1
by: Simon | last post by:
Dear reader, If there is now broken reference in the VBA library and I run the code Mid(;3;2) an error massage can by pop's up "Not a valid instruction". After a reconnection of the...
1
by: Simon | last post by:
Dear reader, The following functions gives me some problems: Mid(,3,2) and Left() and Date(). On one pc it works perfect and on the other one an error message pop's up "Not a valid...
3
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5,...
3
by: wquatan | last post by:
Hi For a parsing routine with more than 100 fields, I'm looking a way to get values out of Fields by determining the Fieldname on the fly. As a simple example : Let's assume the following ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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,...

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.