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. C#
  4. Datagrid not behaving

Datagrid not behaving

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studiodebuggingquestion
2 Posts 1 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.
  • P Offline
    P Offline
    paulb
    wrote on last edited by
    #1

    I have a datagrid bound to a dataset but its not displaying the table - initially all it shows is a '+', if I click on this it expands to 'Tables', and if I click on that I get the table that I want displayed. Can anyone enlighten me as to why it doesn't display the table directly? Here is the database code (all this is done in the Form_Load handler)... OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "User Id=Admin;Password=;" + @"Data Source=C:\Visual Studio Projects\mscale\debug\di-80product.mdb;"; conn.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter(); OleDbCommand selectCmd = new OleDbCommand("SELECT * FROM PRODUCT", conn); adapter.SelectCommand = selectCmd; DataSet ds = new DataSet("ds"); dataGrid1.DataMember = "PRODUCT"; dataGrid1.DataSource = ds; adapter.Fill(ds);

    P 1 Reply Last reply
    0
    • P paulb

      I have a datagrid bound to a dataset but its not displaying the table - initially all it shows is a '+', if I click on this it expands to 'Tables', and if I click on that I get the table that I want displayed. Can anyone enlighten me as to why it doesn't display the table directly? Here is the database code (all this is done in the Form_Load handler)... OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "User Id=Admin;Password=;" + @"Data Source=C:\Visual Studio Projects\mscale\debug\di-80product.mdb;"; conn.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter(); OleDbCommand selectCmd = new OleDbCommand("SELECT * FROM PRODUCT", conn); adapter.SelectCommand = selectCmd; DataSet ds = new DataSet("ds"); dataGrid1.DataMember = "PRODUCT"; dataGrid1.DataSource = ds; adapter.Fill(ds);

      P Offline
      P Offline
      paulb
      wrote on last edited by
      #2

      Never mind, figured this one out finally, all it needed was to specify the table name in the Fill method: adapter.Fill(ds, "PRODUCT"); Bingo! works

      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