排序DATAGRID视图 [英] Sorting DATAGRID VIEW

查看:91
本文介绍了排序DATAGRID视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我已阅读此网站进行排序DATAGRIDVIEW http://vb.net-informations.com/ datagridview / vb.net_datagridview_sort.htm [ ^ ]



我的代码是这样的:



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:

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







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





和我的按钮用于排序datagridview:





and my button for sorting datagridview:

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

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





我的第一栏名为PARTICULARS -varchar(35),其记录如此



''20%项目中的2项''

''20%项目中的1项''

''20%项目中的7项''

''的20%项目''









,我想以自然的方式排序。请帮帮我..



makoy03



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

推荐答案

我想问题是你正试图对具有varchar类型的数据进行比较(>)...只获取来自PARTICULARS的可比较值并将它们CAST到FLOAT然后进行比较....希望这可以帮助你....
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....


这篇关于排序DATAGRID视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆