Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. RRS feed

  • Question

  • User749488471 posted


    I have problem with my code for show data from database to grid, i had to try.. but i can't find it yet..

    give me solution..

    this my code

    Public Class PengaturanTampilan
        Inherits System.Web.UI.Page

        Dim sqlstr As String
        Dim RSP As New ADODB.Recordset
        Dim aduh As New ADODB.Recordset
        Dim cancel As Boolean
        Dim col As Long 'panjang kolom

        Private NamaDBs() As String
        Private NameDBs() As String

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            sqlstr = "provider=MSDataShape;DataProvider=MSDASQL;DRIVER={SQL Server};SERVER="
            sqlstr = sqlstr & Trim(GBLserverName) & ";UID="
            sqlstr = sqlstr & "sa" & ";PWD="
            sqlstr = sqlstr & "password1" & ";DATABASE="
            sqlstr = sqlstr & "AJMweb" & ";"

            If conn.State = 1 Then
            End If

            conn.ConnectionString = sqlstr


            If aduh.State = 1 Then
            End If
            sqlstr = "select * from M_DaftarMnu"
            aduh.Open(sqlstr, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
            'Dim list As New ListItem
            ''Dim dataset As New DataSet
            ''Dim Adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter
            'IList <sqlstr> = New ili
            'IEnumerable.aduh = New IEnumerable.aduh
            'List(Of datakoneksi)= New List(Of datako
            'IEnumerable(Of String) = From M_DaftarMnu In sqlstr Select LabelID
            'List(Of String) =

            If aduh.EOF = False Then
                tampil_grid.DataSource = aduh
                tampil_grid.DataSource = Nothing
            End If

            aduh = Nothing

            'If RSP.State = 1 Then
            '    RSP.Close()
            'End If

            'sqlstr = "select * from M_DaftarMnu order by Caption"
            'RSP.Open(sqlstr, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

            'RSP = Nothing

        End Sub

    Tuesday, February 19, 2013 10:17 PM


  • User-905528745 posted

    You are using OLE DB.  Why????  You must switch to ADO.net.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 19, 2013 11:04 PM