473,320 Members | 2,202 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,320 software developers and data experts.

move rows in a dataview

Sam
Hi,
How can I move a row in my dataview to the first position ?

Thx

Nov 21 '05 #1
1 2026
Hi,

Sorting the dataview will reorder the records. You might have to
add a column to the datatable for sorting
Dim strConn As String
Dim ds As New DataSet
Dim strSQL As String
Dim daEmployees As OleDbDataAdapter
Dim conn As OleDbConnection
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)
da = New OleDbDataAdapter("Select * From Categories", conn)
da.Fill(ds, "Categories")

Dim dcSort As New DataColumn("First", GetType(Integer))
ds.Tables("Categories").Columns.Add(dcSort)

Trace.WriteLine("Before sort")
Dim dv As New DataView(ds.Tables("Categories"))
For Each drvCategories As DataRowView In dv
Trace.WriteLine(drvCategories.Item("Description"))
Next

For Each drvCategories As DataRowView In dv
drvCategories.Item("First") = 1
Next

dv.Item(4).Item("First") = 0
dv.Sort = "First"
Trace.WriteLine("After sort")
For Each drvCategories As DataRowView In dv
Trace.WriteLine(drvCategories.Item("Description"))
Next
Ken
---------------------
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi,
How can I move a row in my dataview to the first position ?

Thx
Nov 21 '05 #2

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

Similar topics

5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
6
by: MrNobody | last post by:
I have a DataGrid sourced by a DataView of a DataTable, and I would like to output the results of any RowFilter operations to a text file. I thought this would be easy but I cannot find where to...
2
by: wh1974 | last post by:
I have a DataTable that I'm binding to a DataList control on my web page. I want to be able to restrict the number of rows that are initially displayed from the DataTable. For example I want to be...
7
by: tshad | last post by:
Is there a way to move a row in a Datalist up or down without having to re-read the data? I have a datalist which has embedded Datagrids in it. I want to allow the user to move a row up or down...
3
by: Rich | last post by:
Hello, If my datagrid is based on a dataTable (t1) and the currency manager is also bound to t1 and I do a find on a key dim dRow As DataRow, t1 As DataTable .... dRow = t1.Rows.find(somekey)...
31
by: One Handed Man \( OHM - Terry Burns \) | last post by:
My Brain is dead !!!!! I modify a single row in a DataTable By setting the FirstName column in a specific row to another name. ( Without Accepting Changes ). However, this statement still...
5
by: Geoff Jones | last post by:
Hi Suppose we have an array of DataRows e.g. Dim drMyRows() As DataRow = myTable.Rows(0).GetChildRows("PricesCompany") generated via a relationship. The question I have is this. Isn't...
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
3
by: G .Net | last post by:
Hi I'm hoping that somebody can help me with the following: I have a DataTable which I'm displaying in a DataGrid. I am changing values in this grid which need to be passed back to the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.