列不属于DGV中的表 [英] Column does not belong to table in DGV

查看:83
本文介绍了列不属于DGV中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim strSQL27 As String = "SELECT STUFF((SELECT DISTINCT '',[''+ FeesType +'']'' FROM FeeMaster WHERE Class=''" & cboClass.Text & "'' For XMl Path('''')), 1, 1, '''')"
        Dim DaAp27 As New SqlDataAdapter(strSQL27, con)
        Dim Dset27 As New DataTable
        DaAp27.Fill(Dset27)






strSQL11 = "SELECT * FROM (SELECT Regno, ST_Name, Class, Section, [FeeType], [Amount_Paid]  FROM Fees_Transaction) stdAdmission" & _
            " PIVOT (Sum(Amount_Paid) for FeeType in (" + Dset27.Rows(0).Item("Column1") + "))as PVTFT where Class=''" & cboClass.Text & "''"


        Dim DaAp11 As New SqlDataAdapter(strSQL11, con)
        Dim DSet11 As New DataTable
        DaAp11.Fill(DSet11)
        DGV1.DataSource = DSet11

        '' How  can i Get Amount PAid Particular Column 

        For Each dr As DataRow In DSet11.Rows
            Me.DataGridView2.Rows.Add()
            With Me.DataGridView2.Rows(Me.DataGridView2.Rows.Count - 1)
                
                For i As Integer = 4 To DataGridView2.ColumnCount - 1
  .Cells(i).Value = dr("Amount_Paid")                Next

            End With
        Next



这里显示此错误我如何解决此问题...

列''Amount_Paid''不属于表格。

推荐答案

通过遍历 DataTable.Columns [ ^ ]属性并检查 DataColumn.ColumnName [ ^ ]属性如何保存此列名称并基于此添加文本。
debug your application by iterating through DataTable.Columns[^] property and check for DataColumn.ColumnName[^] property how it holds this column name and add your text based on that.


这篇关于列不属于DGV中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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