Return a datatable using sqldataadapter in C#

public class testship
{ 
    private static string _cnnString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString(); 
     public static DataTable GetAllShippers()  
    { 
        SqlDataAdapter adp = new SqlDataAdapter( 
            "SELECT * FROM shippers", _cnnString); 
 
        DataSet ds = new DataSet("shippers"); 
        adp.Fill(ds, "shippers"); 
 
        return ds.Tables["shippers"];     
    } 
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.