Convert SqlDataSource to DataTable and DataView

后端 未结 2 1699
渐次进展
渐次进展 2020-12-19 06:50

I have the following SqlDataSource and I want to convert it to DataView and read a column from it:



        
2条回答
  •  悲哀的现实
    2020-12-19 07:52

    The SqlDataSource has a Select method which you can call to get back a DataView from your SqlDataSource - see the MSDN documentation on that.

    SqlDataSource dataSource = new SqlDataSource(connectionString, selectSql);
    DataView view = (DataView)dataSource.Select(args);
    
    DataTable table = view.ToTable();
    

    Is that what you're looking for??

提交回复
热议问题