public DataSet GetData(String tn,String db1)
    { 
        if(db1=="sql")
        {            
        SqlConnection con = new SqlConnection("Integrated security=true;Database=master;server=COMP\\SQLEXPRESS");
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from '"+tn+"", con);
        DataSet ds = new DataSet();
            da.Fill(ds);
        return DataSet;
        }
        
        else  if(db1=="ole")
        {
            OleDbConnection  con=new OleDbConnection("provider=microsoft.jet.4.0;Datasource=c:\\db01.mdb");
            con.Open();
            OleDbDataAdapter da=new OleDbDataAdapter("select * from '"+tn+"'",con);
            DataSet ds=new DataSet();
            da.Fill(ds);
            return DataSet;
        }

Exact error would be more welcomed then code dump upon us to go and see what it may be wrong with it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.