Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
I have this class
C#
class Serach
{
  conect co = new conect();
  public  DataSet ds = new DataSet();
  public DataSet   SearchKarmand(string serch)
  {
    SqlDataAdapter da = new SqlDataAdapter("select * from users", co.conn());
           
    da.Fill(ds);
    return ds;
  }
}

I use this class in main form but only in main form dataset is null

Do you know why?
Posted
Updated 10-Jun-11 19:54pm
v4
Comments
thatraja 11-Jun-11 1:55am    
Show your form code too. Include that in your question
Kim Togo 11-Jun-11 1:57am    
What happens in method "co.conn()", can you post the code in that method?

1 solution

your code seems true there is no error but if you get null dataset then check users table or conncetion string. and put your code in try catch block like....
class Serach
{
  conect co = new conect();
  public  DataSet ds = new DataSet();
  public DataSet   SearchKarmand(string serch)
  {
    try
    {
       SqlDataAdapter da = new SqlDataAdapter("select * from users", co.conn());
       da.Fill(ds);
    }
    catch(Exception ex)
    {
       MessageBox.Show("Error "+ex.Message);
       return null;
    }
    return ds;
  }
}
 
Share this answer
 
Comments
raheleh_es 13-Jun-11 1:38am    
I was check.they have n't any error

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