![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Does anyone know how to sort a data view numerically? By default, when you sort a field from a table in a database, it sorts it in alpha-numerical order. In MS Access, sort is by alpha-numeric, that is, numbers sort from 1, 10 ,11, 1X, 2, 21, 2X, etc. I want VB.NET to sort a column in data view numerically, so it goes 1 - 9, 10 - 19, 20 - 29, etc.. |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
The thing that I would like to do, if it is possible is using a sorting algorithm to sort rows from a table in database. That is, write to a databse and compare the rows and swap the position around in ascending order. One other issue that makes it more complicated is that the primary key field that I would like to base the sort from is that the values are alpha-numeric, e.g. P-1, P-10, P-2, ..., and I would like the sort base it on the numbers that are part of the values so that it sorts the rows in numerical order. That is, the sort should be like as follows from example above; P-1, P-2, ..., P-10, etc. |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
In other words, the new instance of data adapter would execute fine if I left out the cast(substring) statement in the ORDER BY clause, but when I add it in, error is generated. |
|
It seems that it is generating an error due to the mix match of SQL and VB.NET into the SQL statement. What do you think? |
#7
| |||
| |||
|
#8
| ||||
| ||||
|
|
I use Microsoft.Jet.OleDB.4.0 to connect with Microsoft Access 2003. |
|
I'm not using SQL Server. Does this make a difference with entering Transact SQL in .NET? |
|
This is the query I use in .Net is: Dim dbAdapter as New OleDb.OledbAdapter("SELECT * FROM tblISSUE_LIST ORDER BY CAST(SUBSTRING(tblISSUE_LIST.[Issue_No],2,Len(tblISSUE_LIST.[Issue No])-1)) AS INT);", Me.oledbConnection1) Me.IssueDataSet1 MyDataTable = Me.IssueDataSet1.Tables(0) dbAdapter.Fill(MyDataTable) dv = Me.DataSet1.DefaultViewManager.CreateDataView(myDa taTable) . . . |
|
Error occurs when filling the data table to the data adapter. Error is: IErrorInfo.GetDescription failed with E_FAIL(0*80004005). |
#9
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |