本文介绍了错误:无法将类型"Integer"的值转换为"System.Data.DataTable"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我在调用模块到我的表单时出错类型为"Integer"的值不能转换为"System.Data.DataTable"".

我有一个模块可以在列表视图中填充数据,



i have an error to call module to my forms "Value of type ''Integer'' cannot be converted to ''System.Data.DataTable''".

i have a module to fill data in the listview,

Module ModProcedure
      Dim xsize As Integer
      'load data in the listview
      Public Sub FillListView(ByVal sqlData As DataTable, ByVal lvList As ListView, ByVal imageID As Integer)
            Dim i As Integer
            Dim j As Integer
            'lvList.Refresh()
            lvList.Clear()
            For i = 0 To sqlData.Columns.Count - 1
                  lvList.Columns.Add(sqlData.Columns(i).ColumnName)
            Next i

            For i = 0 To sqlData.Rows.Count - 1
                  lvList.Items.Add(sqlData.Rows(i).Item(0), imageID)
                  For j = 1 To sqlData.Columns.Count - 1
                        If Not IsDBNull(sqlData.Rows(i).Item(j)) Then
                              lvList.Items(i).SubItems.Add(sqlData.Rows(i).Item(j))
                        Else
                              lvList.Items(i).SubItems.Add("")
                        End If
                  Next j
            Next i

            For i = 0 To sqlData.Columns.Count - 1
                  xsize = lvList.Width / sqlData.Columns.Count - 8
                  'MsgBox(xsize)
                  'If xsize > 1440 Then
                  lvList.Columns(i).Width = xsize
                  'Else
                  '   lvList.Columns(i).Width = 2000
                  'End If
                  'lvList.Columns(i).AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize)
            Next i
      End Sub---


我曾经在表单中调用此函数,但是在调用数据表时遇到了如下问题


i used to call this function to my form but i am facing problem to call data table as below

Private Sub FrmWHMaster_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


            Dim myCn As New dbconnection
            Dim cnn As New SqlClient.SqlConnection(myCn.Getdbconn)
            Dim sqlStr As String
            ' Try
            cnn.Open()

            sqlStr = "select * from userMaster"


            Dim cmd1 As New SqlClient.SqlCommand(sqlStr, cnn)
            cmd1.CommandType = CommandType.Text
          FillListView(cmd1.ExecuteNonQuery, IstCurrentload, 0)

            cnn.Close()

      End Sub



这是我遇到错误的区域?请咨询.



This is the area i am getting error?please advice.

FillListView(cmd1.ExecuteNonQuery, IstCurrentload, 0)



谢谢,
Ali



Thanks,
Ali

推荐答案



这篇关于错误:无法将类型"Integer"的值转换为"System.Data.DataTable"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 02:54