Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Unable to show data in datagridview

Unable to show data in datagridview

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hisuman100
    wrote on last edited by
    #1

    I am unable to show data on datagridview using the following code. Can anybody help me please. Nothing showing in datagridview but no error message displayed. Suman Dim str As String Dim mycon As New OleDb.OleDbConnection Dim da As OleDbDataAdapter Dim ds As New DataSet Dim dt As New DataTable Dim dv As New DataView str = "Provider=Microsoft.jet.oledb.provider.4.0; Data Source=Nwind.mdb;" mycon.ConnectionString = str mycon.Open() str = "select * from customers" da = New OleDbDataAdapter(str, mycon) da.Fill(ds) DGV.DataSource = ds.DefaultViewManager

    R 1 Reply Last reply
    0
    • H hisuman100

      I am unable to show data on datagridview using the following code. Can anybody help me please. Nothing showing in datagridview but no error message displayed. Suman Dim str As String Dim mycon As New OleDb.OleDbConnection Dim da As OleDbDataAdapter Dim ds As New DataSet Dim dt As New DataTable Dim dv As New DataView str = "Provider=Microsoft.jet.oledb.provider.4.0; Data Source=Nwind.mdb;" mycon.ConnectionString = str mycon.Open() str = "select * from customers" da = New OleDbDataAdapter(str, mycon) da.Fill(ds) DGV.DataSource = ds.DefaultViewManager

      R Offline
      R Offline
      Rupesh Kumar Swami
      wrote on last edited by
      #2

      hi, if dataset contains data(verify it in debug mode) , then try this code DGV.DataSource = ds.Tables(0) in place of

      DGV.DataSource = ds.DefaultViewManager

      hop this helps

      Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

      H 1 Reply Last reply
      0
      • R Rupesh Kumar Swami

        hi, if dataset contains data(verify it in debug mode) , then try this code DGV.DataSource = ds.Tables(0) in place of

        DGV.DataSource = ds.DefaultViewManager

        hop this helps

        Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

        H Offline
        H Offline
        hisuman100
        wrote on last edited by
        #3

        Sorry, it is not working. Should I change any properties to show data? Suman

        R 1 Reply Last reply
        0
        • H hisuman100

          Sorry, it is not working. Should I change any properties to show data? Suman

          R Offline
          R Offline
          Rupesh Kumar Swami
          wrote on last edited by
          #4

          hi suman, there r no mistake in code. are you sure, query return some records ? Verify it in debug mode

          Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

          M 1 Reply Last reply
          0
          • R Rupesh Kumar Swami

            hi suman, there r no mistake in code. are you sure, query return some records ? Verify it in debug mode

            Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

            M Offline
            M Offline
            MBCDC
            wrote on last edited by
            #5

            Good Morning fellows, I always use the following procedure to receive Data from the Jet-Engine or even from the MS-SQL-Server Imports System.Data.OleDb ... Dim oOleDbConnection As OleDbConnection Dim DBAdapt As OleDbDataAdapter Dim DT As New DataTable DIM SQLT as String Dim DBPath as String '***Don't forget to specify the correct databasepath DBPath="C:\mypath\nwind.mdb" Dim sConnString As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & DBPath & ";" & _ "User ID=Admin;" & _ "Password=" oOleDbConnection = New OleDb.OleDbConnection(sConnString) oOleDbConnection.Open() '***check if the Connection had opened correct. If not '***you receive a first tip where the probleme might be If oOleDbConnection.State = ConnectionState.Open Then '***Set the SQL-Statement SQLT="Select * from Customer;" '***Create a new Adapter-Object Dim DBAdapt As New OleDbDataAdapter(SQLT, oOleDbConnection) '***Because of the fact that we only select Data from one Table '***it is enough to use a DataTable Object instead of a DataSet '***And now lets fill it! OleDbDataAdapter.Fill(DT) '***we don't need the connection to be open longer, so lets close it. oOleDbConnection.Close() '***it will be better to give a Name to the DataTable.... DT.TableName="Customer" '***lets bind the DataTable to a DataGridView DGV.DataSource=DT '***Thats all! This should work! Else Call MsGBox("Connection not open!") End If

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups