|
Subject:
|
denotes a 'field' where a 'class' was expected
|
|
Posted By:
|
jdang67
|
Post Date:
|
11/12/2004 2:29:20 PM
|
Hi all,
I have a little problem with the connection object. when I compile, it gave me error:
...CustomerManager.connection' denotes a 'field' where a 'class' was expected
I have no ideal why. I shoud be able to have a SqlConnection object as a field in CustomerManager class right? How can I fix this?
Thanks
John
1) I have ConnectionManager class have 1 public method that return an opened SqlConnection object
public class ConnectionManager {
public static SqlConnection getConnection() {
SqlConnection connection = new SqlConnection (SQL_CONNECTION_STRING_POOL); connection.Open(); return connection;
} }
2. I have another class call CustomerManager that have some methods in this case , I just show 1 method: addCustomer.
public class CustomerManager {
SqlConnection connection = ConnectionManager.getConnection();
public static bool addCustomer(Customer cust) {
// codes here // // line 100 SqlCommand command = new SqlCommand(sql, connection); // code here
}
}
|
|
Reply By:
|
jdang67
|
Reply Date:
|
11/12/2004 2:39:40 PM
|
I see the problem since the addCustomer(customer in) is static then the connection field will not be initialized.
John
|
|