My program compiles correctly in VS 2003 but fails in VS2005 Express Edition
- I get a compile error
Inconsistent accessibility: return type 'VA.Customer' is less accessible
than method 'VA.CustomerDB.GetCustomer(string)'
Here is a snippet
public class CustomerDB
{
public static DataTable GetCustomers()
{
string selectStatement = "SELECT CustomerID, FirstName, LastName "
+ "FROM Customers "
+ "ORDER BY CustomerID";
SqlCommand SelectCommand =
new SqlCommand(selectStatement, GetConnection());
SqlDataAdapter customersDataAdapter =
new SqlDataAdapter(SelectCommand);
DataSet customersDataSet = new DataSet();
customersDataAdapter.Fill(customersDataSet, "Customers");
return customersDataSet.Tables["CustomerID"];
}
public static Customer GetCustomer(string customerID)
{
SqlConnection VAConnection = GetConnection();
string selectStatement = "SELECT CustomerID, FirstName, LastName"
+ "FROM Customers "
+ "WHERE CustomerID = @CustomerID";
SqlCommand selectCommand =
new SqlCommand(selectStatement, VAConnection);
selectCommand.Parameters.Add("@CustomerID", customerID);
SqlDataReader customerReader;
VAConnection.Open();
customerReader =
selectCommand.EndExecuteReader(CommandBehavior.Sin gleRow);
if (customerReader.Read())
{
Customer customer = new Customer();
customer.CustomerID = (string) customerReader["CustomerID"];
customer.FirstName = (string) customerReader["FirstName"];
customer.LastName = (string) customerReader["LastName"];
VAConnection.Close();
return customer;
}
else
{
VAConnection.Close();
return null;
}
}
The customer class has been defined in a simple format as follows:
class Customer
{
public string CustomerID;
public string FirstName;
public string MiddleName;
public string LastName;
}
Any help would be appreciated - Thanks 5 2646
Hello
I am surprised you say this code compiles in VS 2003, it shouldn't. I think
you changed something
To solve the problem make the GetCustomer method internal or make the
Customer class public.
Best regards,
Sherif
"hodari" <ho****@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com... My program compiles correctly in VS 2003 but fails in VS2005 Express
Edition - I get a compile error
Inconsistent accessibility: return type 'VA.Customer' is less accessible than method 'VA.CustomerDB.GetCustomer(string)'
Here is a snippet
public class CustomerDB { public static DataTable GetCustomers() { string selectStatement = "SELECT CustomerID, FirstName,
LastName " + "FROM Customers " + "ORDER BY CustomerID"; SqlCommand SelectCommand = new SqlCommand(selectStatement, GetConnection()); SqlDataAdapter customersDataAdapter = new SqlDataAdapter(SelectCommand); DataSet customersDataSet = new DataSet(); customersDataAdapter.Fill(customersDataSet, "Customers"); return customersDataSet.Tables["CustomerID"]; }
public static Customer GetCustomer(string customerID) { SqlConnection VAConnection = GetConnection(); string selectStatement = "SELECT CustomerID, FirstName,
LastName" + "FROM Customers " + "WHERE CustomerID = @CustomerID"; SqlCommand selectCommand = new SqlCommand(selectStatement, VAConnection); selectCommand.Parameters.Add("@CustomerID", customerID); SqlDataReader customerReader; VAConnection.Open(); customerReader = selectCommand.EndExecuteReader(CommandBehavior.Sin gleRow); if (customerReader.Read()) { Customer customer = new Customer(); customer.CustomerID = (string)
customerReader["CustomerID"]; customer.FirstName = (string) customerReader["FirstName"]; customer.LastName = (string) customerReader["LastName"]; VAConnection.Close(); return customer; } else { VAConnection.Close(); return null; } }
The customer class has been defined in a simple format as follows:
class Customer { public string CustomerID; public string FirstName; public string MiddleName; public string LastName;
}
Any help would be appreciated - Thanks
Thanks Sherif - much appreciated. Yes it does compile in VS2003 quirky I
might say.
I made the customer class public and that solved the problem. However, what
are the ramifications for doing that from an architectural point of view?
Regards
Hussein
"Sherif ElMetainy" wrote: Hello
I am surprised you say this code compiles in VS 2003, it shouldn't. I think you changed something To solve the problem make the GetCustomer method internal or make the Customer class public.
Best regards, Sherif
"hodari" <ho****@discussions.microsoft.com> wrote in message news:AC**********************************@microsof t.com... My program compiles correctly in VS 2003 but fails in VS2005 Express Edition - I get a compile error
Inconsistent accessibility: return type 'VA.Customer' is less accessible than method 'VA.CustomerDB.GetCustomer(string)'
Here is a snippet
public class CustomerDB { public static DataTable GetCustomers() { string selectStatement = "SELECT CustomerID, FirstName, LastName " + "FROM Customers " + "ORDER BY CustomerID"; SqlCommand SelectCommand = new SqlCommand(selectStatement, GetConnection()); SqlDataAdapter customersDataAdapter = new SqlDataAdapter(SelectCommand); DataSet customersDataSet = new DataSet(); customersDataAdapter.Fill(customersDataSet, "Customers"); return customersDataSet.Tables["CustomerID"]; }
public static Customer GetCustomer(string customerID) { SqlConnection VAConnection = GetConnection(); string selectStatement = "SELECT CustomerID, FirstName, LastName" + "FROM Customers " + "WHERE CustomerID = @CustomerID"; SqlCommand selectCommand = new SqlCommand(selectStatement, VAConnection); selectCommand.Parameters.Add("@CustomerID", customerID); SqlDataReader customerReader; VAConnection.Open(); customerReader = selectCommand.EndExecuteReader(CommandBehavior.Sin gleRow); if (customerReader.Read()) { Customer customer = new Customer(); customer.CustomerID = (string) customerReader["CustomerID"]; customer.FirstName = (string) customerReader["FirstName"]; customer.LastName = (string) customerReader["LastName"]; VAConnection.Close(); return customer; } else { VAConnection.Close(); return null; } }
The customer class has been defined in a simple format as follows:
class Customer { public string CustomerID; public string FirstName; public string MiddleName; public string LastName;
}
Any help would be appreciated - Thanks
Hello
Making the Customer class public, means that other it can be referenced from
other assemblies. If your project is an exe, in most cases, it doesn't
matter, since assemblies usually reference DLLs. If your project is a DLL
you are making the Customer class visible for other assemblies. This means
that if you release another version of you assembly you cannot rename/remove
the Customer class or any of its public members so that you don't break
assemblies depending on your assembly.
Best regards,
Sherif
"hodari" <ho****@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com... Thanks Sherif - much appreciated. Yes it does compile in VS2003 quirky I might say.
I made the customer class public and that solved the problem. However,
what are the ramifications for doing that from an architectural point of view?
Regards
Hussein
"Sherif ElMetainy" wrote:
Hello
I am surprised you say this code compiles in VS 2003, it shouldn't. I
think you changed something To solve the problem make the GetCustomer method internal or make the Customer class public.
Best regards, Sherif
"hodari" <ho****@discussions.microsoft.com> wrote in message news:AC**********************************@microsof t.com... My program compiles correctly in VS 2003 but fails in VS2005 Express Edition - I get a compile error
Inconsistent accessibility: return type 'VA.Customer' is less
accessible than method 'VA.CustomerDB.GetCustomer(string)'
Here is a snippet
public class CustomerDB { public static DataTable GetCustomers() { string selectStatement = "SELECT CustomerID, FirstName, LastName " + "FROM Customers " + "ORDER BY CustomerID"; SqlCommand SelectCommand = new SqlCommand(selectStatement, GetConnection()); SqlDataAdapter customersDataAdapter = new SqlDataAdapter(SelectCommand); DataSet customersDataSet = new DataSet(); customersDataAdapter.Fill(customersDataSet, "Customers"); return customersDataSet.Tables["CustomerID"]; }
public static Customer GetCustomer(string customerID) { SqlConnection VAConnection = GetConnection(); string selectStatement = "SELECT CustomerID, FirstName, LastName" + "FROM Customers " + "WHERE CustomerID = @CustomerID"; SqlCommand selectCommand = new SqlCommand(selectStatement, VAConnection); selectCommand.Parameters.Add("@CustomerID", customerID); SqlDataReader customerReader; VAConnection.Open(); customerReader = selectCommand.EndExecuteReader(CommandBehavior.Sin gleRow); if (customerReader.Read()) { Customer customer = new Customer(); customer.CustomerID = (string) customerReader["CustomerID"]; customer.FirstName = (string)
customerReader["FirstName"]; customer.LastName = (string)
customerReader["LastName"]; VAConnection.Close(); return customer; } else { VAConnection.Close(); return null; } }
The customer class has been defined in a simple format as follows:
class Customer { public string CustomerID; public string FirstName; public string MiddleName; public string LastName;
}
Any help would be appreciated - Thanks
Thank You Very Much - appreciated
"Sherif ElMetainy" wrote: Hello
Making the Customer class public, means that other it can be referenced from other assemblies. If your project is an exe, in most cases, it doesn't matter, since assemblies usually reference DLLs. If your project is a DLL you are making the Customer class visible for other assemblies. This means that if you release another version of you assembly you cannot rename/remove the Customer class or any of its public members so that you don't break assemblies depending on your assembly.
Best regards, Sherif "hodari" <ho****@discussions.microsoft.com> wrote in message news:B0**********************************@microsof t.com... Thanks Sherif - much appreciated. Yes it does compile in VS2003 quirky I might say.
I made the customer class public and that solved the problem. However, what are the ramifications for doing that from an architectural point of view?
Regards
Hussein
"Sherif ElMetainy" wrote:
Hello
I am surprised you say this code compiles in VS 2003, it shouldn't. I think you changed something To solve the problem make the GetCustomer method internal or make the Customer class public.
Best regards, Sherif
"hodari" <ho****@discussions.microsoft.com> wrote in message news:AC**********************************@microsof t.com... > My program compiles correctly in VS 2003 but fails in VS2005 Express Edition > - I get a compile error > > Inconsistent accessibility: return type 'VA.Customer' is less accessible > than method 'VA.CustomerDB.GetCustomer(string)' > > Here is a snippet > > public class CustomerDB > { > public static DataTable GetCustomers() > { > string selectStatement = "SELECT CustomerID, FirstName, LastName " > + "FROM Customers " > + "ORDER BY CustomerID"; > SqlCommand SelectCommand = > new SqlCommand(selectStatement, GetConnection()); > SqlDataAdapter customersDataAdapter = > new SqlDataAdapter(SelectCommand); > DataSet customersDataSet = new DataSet(); > customersDataAdapter.Fill(customersDataSet, "Customers"); > return customersDataSet.Tables["CustomerID"]; > } > > > public static Customer GetCustomer(string customerID) > { > SqlConnection VAConnection = GetConnection(); > string selectStatement = "SELECT CustomerID, FirstName, LastName" > + "FROM Customers " > + "WHERE CustomerID = @CustomerID"; > SqlCommand selectCommand = > new SqlCommand(selectStatement, VAConnection); > selectCommand.Parameters.Add("@CustomerID", customerID); > SqlDataReader customerReader; > VAConnection.Open(); > customerReader = > selectCommand.EndExecuteReader(CommandBehavior.Sin gleRow); > if (customerReader.Read()) > { > Customer customer = new Customer(); > customer.CustomerID = (string) customerReader["CustomerID"]; > customer.FirstName = (string) customerReader["FirstName"]; > customer.LastName = (string) customerReader["LastName"]; > VAConnection.Close(); > return customer; > } > else > { > VAConnection.Close(); > return null; > } > } > > The customer class has been defined in a simple format as follows: > > class Customer > { > public string CustomerID; > public string FirstName; > public string MiddleName; > public string LastName; > > } > > Any help would be appreciated - Thanks
hodari <ho****@discussions.microsoft.com> wrote: Thanks Sherif - much appreciated. Yes it does compile in VS2003 quirky I might say.
Could you post a complete program to demonstrate that? It sounds very
odd, as I've seen the compiler correctly report the inconsistent
accessibility problem before.
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I'm looking for.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt |
last post by:
I'm new to Java but experienced with PL/SQL. I've found what appears to be
strange behaviour (a bug?) when attempting to create java stored objects
using the UNIX version of Oracle SQL*PLUS...
|
by: Jerzy Karczmarczuk |
last post by:
Gurus, before I am tempted to signal this as a bug, perhaps
you might convince me that it should be so. If I type
l=range(4)
l.extend()
l gives , what else...
On the other hand, try
|
by: Darrin |
last post by:
Hello,
I see that VS2005 and the new framework 2.0 is out to the public now.
Wondering about some things.
When you install the new framework 2.0 can a person still use visual studio
2003 or...
|
by: Samuel |
last post by:
Hi All,
I am in the process of converting a VS 2003 project to VS 2005 project (VB.NET Class Library).
It gives the error in TypeOf and DirectCast statements. It was working...
|
by: dlasusa |
last post by:
Sorry if this is the wrong group...I THINK I got to the right
place...(oh...and I'm a newbie programmer...so please be gentle)
Anyway I have a program that works fine when I run it from within...
|
by: nicknack |
last post by:
Hello.
I have a pc with visual studio 2005 working well.
I tried to install VS2003 along with the VS2003 so I can work on an
old project built with VS2003 and FW1.1.
The problem is that when...
|
by: fred64 |
last post by:
Hello ,
I fought very hard and succeed to do a remote debug from a client
with
VS2003 on XP HOME to a Server with XP PRO. This is on a Workgroup :
I
created same user/pwd with admin rights...
|
by: petinboy |
last post by:
Hi All!
I am developing an accessibility keyboard application with Visual Studio 2005 Professional Edition and with C#. The application is a keyboard with buttons that interacts with any...
|
by: kjr11mjr |
last post by:
Hi,
I am having trouble referencing a dll in visual studio 2003. where as that same dll is easily refrenced on 2005. the error msg is:
"A reference to **********.dll could not be added. It is not...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
| |