none
sqlite datatable to DataGridView RRS feed

  • Question

  • i used this script with my Access DB and it worked great but after changing to SQLite got an ERROR:

    System.Data.EvaluateException: Cannot find column [b.c_name].
    Public Shared Function Con_SQLite(ByVal commandString As String)
            Dim mycon As New SQLiteConnection()
    
            Try
                mycon.ConnectionString = "data source= " & SQLite_db
                mycon.Open()
    
                Dim da As New SQLiteDataAdapter(commandString, mycon)
                Dim ds As New DataSet()
                da.Fill(ds)
                Dim dt As DataTable
                dt = ds.Tables(0)
                mycon.Close()
    
                Return dt
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    
        End Function
    
    Dim dt as datatable = Con_SQLite("Select a.c_name  ,b.* from companies a left join D_Year b on a.c_name=b.c_name")
    
    
    Dim dv As DataView
            dv = New DataView(dt, "b.c_name is null, "a.c_name ", DataViewRowState.CurrentRows)
            DataGridView1.RowHeadersVisible = False
            DataGridView1.DataSource = dv
            DataGridView1.Columns(0).Visible = False
            DataGridView1.Columns(1).HeaderText = "customer"
            DataGridView1.Columns(1).Width = 500
            For i As Integer = 2 To DataGridView1.ColumnCount - 1
                DataGridView1.Columns.Remove(DataGridView1.Columns(2).Name)
            Next


    • Edited by noampro8 Sunday, May 20, 2018 8:20 AM
    Sunday, May 20, 2018 8:19 AM

All replies