column inaccessible due to its protection level

  • Thread starter Thread starter Tim Smith
  • Start date Start date
T

Tim Smith

Hi,

I have a test driver that is in my remoting service project and I am
able to use the following code to reference a particular field:

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

This is great because if my dataset column ever changes I will know
about it on compile.

However when I have another project, which references that project and
gets the dataset back and attempts the same code I get the message:

column inaccessible due to its protection level

It would be a tragedy (travesty?) to lose compile time checking - any
ideas on how I can get access to the datacolumn id by name?

thanks

Tim
 
Tim,

Since you mention,

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

My answer assumes, the way you are using Compile Time checking, is using a
strongly typed dataset (right?).

And since you mention remoting, I assume that your solution is split into a
remoting service, and a remoting client (right?)

Well, you could put this strongly typed dataset in a common dll, and share
it on both ends? This would be the common data dll, say where all the
interfaces reside. So if you have a customer object, you would define it as
ICustomer in both the server and the client, and you'd do that thru a common
dll (or soapsuds, but don't use soapsuds).

Obviously, my answer is based on a lot of assumptions :)

Anyway, to answer your question at a macro level, "any ideas on how I can
get access to the datacolumn id by name?" -> There is a function just for
that called "GetOrdinal" on DataReaders, you could put code in the
constructor of the object that looks like

#IF DEBUG
DataReader.GetOrdinal("MyColumn") // debug.assert false if this doesn't
work
#ENDIF

While it won't catch it on compile time, it will catch it on the first ever
run (which isn't terrible huh?), but I still like my earlier answer.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/
 
Thanks for your reply. I am referring to a typed dataset and I do
have a DLL reference to where the dataset exists.

However outside the project (class library/dll) I cannot access the
column name directly.

Having error at runtime, regardless of first time or not weakens the
architecture significantly.

It almost seems like I need to include the datasets in each project
referencing my services - or auto generate a class with all the column
names to prevent typos on the column name.

Tim

Sahil Malik said:
Tim,

Since you mention,

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

My answer assumes, the way you are using Compile Time checking, is using a
strongly typed dataset (right?).

And since you mention remoting, I assume that your solution is split into a
remoting service, and a remoting client (right?)

Well, you could put this strongly typed dataset in a common dll, and share
it on both ends? This would be the common data dll, say where all the
interfaces reside. So if you have a customer object, you would define it as
ICustomer in both the server and the client, and you'd do that thru a common
dll (or soapsuds, but don't use soapsuds).

Obviously, my answer is based on a lot of assumptions :)

Anyway, to answer your question at a macro level, "any ideas on how I can
get access to the datacolumn id by name?" -> There is a function just for
that called "GetOrdinal" on DataReaders, you could put code in the
constructor of the object that looks like

#IF DEBUG
DataReader.GetOrdinal("MyColumn") // debug.assert false if this doesn't
work
#ENDIF

While it won't catch it on compile time, it will catch it on the first ever
run (which isn't terrible huh?), but I still like my earlier answer.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



Tim Smith said:
Hi,

I have a test driver that is in my remoting service project and I am
able to use the following code to reference a particular field:

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

This is great because if my dataset column ever changes I will know
about it on compile.

However when I have another project, which references that project and
gets the dataset back and attempts the same code I get the message:

column inaccessible due to its protection level

It would be a tragedy (travesty?) to lose compile time checking - any
ideas on how I can get access to the datacolumn id by name?

thanks

Tim
 
I would recommend referencing the datasets in each project, versus
auto-generating XSD's.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



Tim Smith said:
Thanks for your reply. I am referring to a typed dataset and I do
have a DLL reference to where the dataset exists.

However outside the project (class library/dll) I cannot access the
column name directly.

Having error at runtime, regardless of first time or not weakens the
architecture significantly.

It almost seems like I need to include the datasets in each project
referencing my services - or auto generate a class with all the column
names to prevent typos on the column name.

Tim

"Sahil Malik" <[email protected]> wrote in message
Tim,

Since you mention,

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

My answer assumes, the way you are using Compile Time checking, is using a
strongly typed dataset (right?).

And since you mention remoting, I assume that your solution is split into a
remoting service, and a remoting client (right?)

Well, you could put this strongly typed dataset in a common dll, and share
it on both ends? This would be the common data dll, say where all the
interfaces reside. So if you have a customer object, you would define it as
ICustomer in both the server and the client, and you'd do that thru a common
dll (or soapsuds, but don't use soapsuds).

Obviously, my answer is based on a lot of assumptions :)

Anyway, to answer your question at a macro level, "any ideas on how I can
get access to the datacolumn id by name?" -> There is a function just for
that called "GetOrdinal" on DataReaders, you could put code in the
constructor of the object that looks like

#IF DEBUG
DataReader.GetOrdinal("MyColumn") // debug.assert false if this doesn't
work
#ENDIF

While it won't catch it on compile time, it will catch it on the first ever
run (which isn't terrible huh?), but I still like my earlier answer.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



Tim Smith said:
Hi,

I have a test driver that is in my remoting service project and I am
able to use the following code to reference a particular field:

myDataSet.MYTABLE[0][myDataSet.MYTABLE.PERSON_IDColumn] = 5;

This is great because if my dataset column ever changes I will know
about it on compile.

However when I have another project, which references that project and
gets the dataset back and attempts the same code I get the message:

column inaccessible due to its protection level

It would be a tragedy (travesty?) to lose compile time checking - any
ideas on how I can get access to the datacolumn id by name?

thanks

Tim
 
Back
Top