Thursday, March 22, 2012

copying SQLDataSource Data into DataSet

is there a way to copy a SqlDataSource Data into a dataset?http://forums.asp.net/thread/1278086.aspx|||

alt solution...

string connectionString = "...Northwind Connection String...";
string selectSql = "SELECT [CategoryID], [CategoryName] FROM [Categories]";

DataSourceSelectArguments args = new DataSourceSelectArguments();

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

DataTable table = view.ToTable();

found here...

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=228386&SiteID=1

|||
DataView dv=(DataView)(SqlDataSource1.Select(DataSourceSelectArguments.Empty));DataSet newDS =new DataSet(); DataTable dt = dv.Table.Clone();foreach (DataRowView drvin dv)dt.ImportRow(drv.Row);newDS.Tables.Add(dt);
|||Thank You all. Somehow I was not able to find a solutions. All of these solutions worked great.

No comments:

Post a Comment