I was madly trying to do this simple operation:
extracts data from sqldatasource and puts them in variables that I can manipulate.
In the end, here is the working code for this for VB.NET:
Dim DV As New DataView() Dim DataTable As New DataTable() Dim SqlDataSource1 As New SqlDataSource() Dim VALUE As String SqlDataSource1.ID = "SqlDataSource1" Me.Page.Controls.Add(SqlDataSource1) SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("Connection_name").ConnectionString SqlDataSource1.SelectCommand = "SELECT * from Table" DV = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView) DataTable = DV.ToTable() For Each riga As DataRow In DataTable.Rows VALUE = riga("table_name").ToString Next
"for each", in this case, gets only the first value, but you can get any value from the datatable and put it in a vector or other lines so that you can control the data coming from sqldatasource.
ENJOY
Giorgio C.
source share