Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi
here i need to know How TO call object Form One Class method to another class Method
here situation is as Follows:
This Is One Class
C#
namespace XXX
{
public class YYY
{
 
 public static DataTable table(String query)
        {
            MySqlDataAdapter Adp = new MySqlDataAdapter(query, SqlConnection);
            DataTable dataTable = new DataTable();
            Adp .Fill(dataTable);
            return dataTable;
        }
}
}


Another Class Is
C#
namespace XXX
{
public class ZZZ
{
  public object[] InsertParameters(XXX.yyy device)
{
  Here I should call  "Adp " Object 
}


My Code should be Like this:{Here i need to call above classYYY object)
C#
 public object[] InsertParameters(XXX.yyy device)
{
            Adp .Parameters.AddWithValue("@s", device.s);
            Adp .Parameters.AddWithValue("@f", device.f);
            Adp .Parameters.AddWithValue("@c", device.c);
            Adp .Parameters.AddWithValue("@z", device.z);
}
Posted
Updated 21-Jun-12 1:20am
v2

1 solution

It's not possible in the current implementation due the fact that Adp is a variable inside a method... you have make Adp a member of the class and make it public (e.g. inside a public property) if you want to have it available.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900