473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB SqlDataSource.Select

Hi, I am writing my first web app in VB.Net, after being very familiar
with C#.Net. I am trying to store the results of the
SqlDataSource.Select() method. In C#, the select method returns a
DataView, which you can manipulate very easily. But I have not had
success using the same method in VB. I did have success using
Enumerators, but i would like to work with the data in a DataTable.

here is some of my code:

in C#:

DataView dv = (DataView)
sdsDataSource.Select(DataSourceSelectArguments.Emp ty);
int count = dv.Table.Rows.Count();
...... whatever else
in VB, i got this to work

Dim ie As IEnumerable
ie = sdsDataSource.Select(DataSourceSelectArguments.Emp ty)
Dim dt As IEnumerator = ie.GetEnumerator()
while dt.MoveNext()
Dim dr As System.Data.DataRowView = dt.Current()
Response.Write(dr(0).ToString())
....whatever else
end while

Is it possible to cast an IEnumberable as a DataView or DataTable? I
really want to be able to count the number of rows, and work with the
data in a DataTable.

Thanks!

Jun 18 '07 #1
2 8706
I guess i really just needed to hear my problem out loud! after i
wrote it, i did it the same way as C#............

VB

Dim dv As System.Data.DataView
dv = CType(sdsGetFormNo.Select(DataSourceSelectArgument s.Empty),
System.Data.DataView)
Dim myField As String = dv.Table.Rows(0)(0).ToString()
Hope this can help someone else!

Jun 18 '07 #2
And similarly you have a for each (two words) statement instead of
enumerating by hand in case you would need that at a later time...

---
Patrice

<ms********@gmail.coma écrit dans le message de news:
11*********************@k79g2000hse.googlegroups.c om...
>I guess i really just needed to hear my problem out loud! after i
wrote it, i did it the same way as C#............

VB

Dim dv As System.Data.DataView
dv = CType(sdsGetFormNo.Select(DataSourceSelectArgument s.Empty),
System.Data.DataView)
Dim myField As String = dv.Table.Rows(0)(0).ToString()
Hope this can help someone else!

Jun 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
3
by: zapov | last post by:
Hi! Did anyone successfully managed to use some custom ADO.NET provider with SqlDataSource? I'd like to connect to some other database than MSSQL (like MySQL, Firebird or PostgreSQL) but I'm...
3
by: simonZ | last post by:
In gridView I have dropdown list : <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField...
0
by: cyberbless | last post by:
I would like to dynamically assign a Select Statment to a a SqlDataSource. Problem is the SqlDataSource.Select() Command requires a "dataSourceSelectArgument" as one of its arguments. 1. What...
4
by: | last post by:
I'm building some user controls. I very much like how you can build custom properties to be bound to a user control, and how instances of that control will show those custom properties in the...
3
by: Daniel R. H. | last post by:
Hi, I'm having problems to get the value of a Querystring into the SelectCommand of a SQLDataSource, here's my code: ---------------------------------------------- <asp:SqlDataSource...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
2
by: Brad Isaacs | last post by:
Good evening friends, I have added a Drop Down List box control to my web form. I am using the web.config connection string to access my SQL Server 2000 db. Inside that db I have a table named...
2
by: Julien Sobrier | last post by:
Hello, I have 2 SqlDataSource on the same page that retrieve the same column names: <asp:SqlDataSource ID="SqlStructure" runat="server" SelectCommand="SELECT a, b FROM c WHERE d = 0 /> ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.