Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2004, 12:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default Loosing a reference??

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
__________________
- mega
Aspiring JavaScript Ninja
 
Old November 27th, 2004, 06:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

I got the answer here: http://www.gotdotnet.com/Community/M...&Page=1#282952

 - mega
Moving to C# .NET





Similar Threads
Thread Thread Starter Forum Replies Last Post
Loosing work Patc4 VB.NET 2002/2003 Basics 4 March 28th, 2008 08:14 AM
Form Loosing Data netpicker9 General .NET 1 June 14th, 2007 08:12 PM
get reference name demac43 Excel VBA 2 November 20th, 2006 02:35 PM
in need of reference! alialibidad SQL Language 1 June 4th, 2006 05:14 AM
in need of reference! alialibidad ASP.NET 2.0 Professional 0 June 3rd, 2006 04:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.