Answered by:
sorting the record in descending order

Question
-
User-656010581 posted
hi,
i m using asp.net 2005 with access 2003. i need a code using vb.
how can i sort the record in descending order? help anyone.........
Friday, August 13, 2010 10:33 PM
Answers
-
User-97507017 posted
Public Class Form1 Dim con As OleDb.OleDbConnection Dim cmd As OleDb.OleDbCommand Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con = New OleDb.OleDbConnection("Connection String") con.Open() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As String str = "insert into stud values(" & (txtno.Text) & ",'" & (txtname.Text) & "')" cmd = New OleDb.OleDbCommand(str, con) cmd.ExecuteNonQuery() MsgBox("Inserted") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cmd1 As OleDb.OleDbDataAdapter Dim ds As New DataSet cmd1 = New OleDb.OleDbDataAdapter("select * from stud order by sno", con) ds.Clear() cmd1.Fill(ds, "stud") DataGridView1.DataSource = ds.Tables(0) End Sub End Class
Wat ever column u wanna to b descending order u can mention field name.... it will sorted and display in the gridview...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 14, 2010 2:01 AM
All replies
-
User1992938117 posted
Check below link
http://msdn.microsoft.com/en-us/library/bb208913%28v=office.12%29.aspx
http://www.fmsinc.com/tpapers/queries/index.html
http://www.blueclaw-db.com/accessquerysql/
Thanks..
Saturday, August 14, 2010 1:26 AM -
User-97507017 posted
Public Class Form1 Dim con As OleDb.OleDbConnection Dim cmd As OleDb.OleDbCommand Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con = New OleDb.OleDbConnection("Connection String") con.Open() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As String str = "insert into stud values(" & (txtno.Text) & ",'" & (txtname.Text) & "')" cmd = New OleDb.OleDbCommand(str, con) cmd.ExecuteNonQuery() MsgBox("Inserted") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cmd1 As OleDb.OleDbDataAdapter Dim ds As New DataSet cmd1 = New OleDb.OleDbDataAdapter("select * from stud order by sno", con) ds.Clear() cmd1.Fill(ds, "stud") DataGridView1.DataSource = ds.Tables(0) End Sub End Class
Wat ever column u wanna to b descending order u can mention field name.... it will sorted and display in the gridview...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 14, 2010 2:01 AM -
User-656010581 posted
Thanks alot for helping me
. i really did know wat to do. but now your code is helping me more.........
-dharsini
Monday, August 16, 2010 11:15 AM