Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello I have read this site for sorting DATAGRIDVIEW http://vb.net-informations.com/datagridview/vb.net_datagridview_sort.htm[^]

and had my code that is like this:

VB
Public conmainWin As String = "user=SYSDBA;password=masterkey;DataBase=C:\My_Database\CLIENT_CUSTOMER.FDB; datasource=localhost;Port=3050;Dialect=3;Charset=ASCII;Role=SA;Connection Lifetime=0;Connection timeout=15;pooling=true;packet size=8192;server type=0" 'DB path GFLINVENTORY
    Public fbcon As New FbConnection    'FOR FB CONNECTION
    Public fbcmd As FbCommand           'TO EXECUTE FB COMMAND
    Public fbdr As FbDataReader         'TO READ FB DATA
    Public sql As String


Public Sub DBAddUpdate(ByVal sqlAddUpd As String)
        Try
            fbcon = New FbConnection(conmainWin)
            fbcon.Open()
            sql = sqlAddUpd
            fbcmd = New FbCommand(sql, fbcon)
            fbcmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


VB
Public Sub DBClose()
        fbcon.Close()
        fbcon.Dispose()
    End Sub


and my button for sorting datagridview:

VB
Try
            Call DBAddUpdate("SELECT * FROM UNPAID_FORM")
            DBClose()

            Dim fireBirdCon As New FbConnection
            fireBirdCon = New FbConnection(conmainWin)
            Dim firebirdAdap As New FbDataAdapter(sql, fireBirdCon)
            Dim FBds As New gflSOADataSet
            fireBirdCon.Open()
            firebirdAdap.Fill(FBds, "UNPAID_FORM")
            fireBirdCon.Close()

            Dim dataVw As New DataView

            dataVw = New DataView(FBds.Tables(1), "PARTICULARS > 19", "PARTICULARS ASC", DataViewRowState.CurrentRows)
            UNPAID_FORMDataGridView.DataSource = dataVw

            MsgBox("Item sorted.", MsgBoxStyle.Information Or MsgBoxStyle.OkOnly, "Information Retrieved")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error!")
        End Try

but had exception error that goes like this: Cannot find column [PARTICULARS] in code line

VB
dataVw = New DataView(FBds.Tables(1), "PARTICULARS > 19", "PARTICULARS ASC", DataViewRowState.CurrentRows)


my first column is named PARTICULARS -varchar(35) that has record that goes like this"

'2 of 20% item'
'1 of 20% item'
'7 of 20% item'
'3 of 20% item'
.
.
.

that i wanted to sort in a natural way. Please help me..

makoy03
Posted

1 solution

Hi, i think the problem is you are trying to do comparison ( > ) for data which has the type of varchar...get only the comparable values from PARTICULARS and CAST them to FLOAT and then do the comparison....hope this helps you....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900