Hi.
The compiler doesnât recognize an argument sent to a method, even though the latter argument works as expected. It's like I loose my parameters after I call another method in my class. Do any of you guys see the connection? I must admit I'm confused.
Code:
public void InstantiateClass(Object obj, string cmd)
{
OleDbDataReader reader = this.Select(cmd, false);//call DBTool.Select to fill the DataReader
while (reader.Read())
{
object [,] fields = new object[reader.FieldCount, 2];
for(int i = 0; i < reader.FieldCount; i++)
{
fields[i,0] = reader.GetFieldType(i);
fields[i,1] = reader[i];
}
}
if (typeof(obj) is Customer.School) // obj is not recognized as a parameter
Console.WriteLine("This is a School object");
}
Here is the code that calls the InstatiateClass method of the DBTool class.
Code:
static void Main(string[] args)
{
string cmd = @"SELECT Customers.CustomerID, Customers.Password, Customers.Name, "+
@" Customers.Address, Customers.ZipCode, Customers.City," +
@"Customers.Phone, Customers.EMail, Customers.PaymentRecord, " +
@"Customers.OldCustomer, Customers.CreditAmount, Customers.Balance, " +
@"Customers.CName FROM Customers WHERE (((Customers.CustomerID)=1));";
Customer.School objSchool = new Customer.School();
DBTool myTool = new DBTool();
myTool.InstantiateClass(objSchool, cmd);
- mega
Moving to C# .NET