Results 1 to 6 of 6

Thread: dbgrid problem - Help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    4

    dbgrid problem - Help!

    Hi,
    I have populated a dbgrid with data from a table in the access data base by binding the data grid to a datasource through code. When I run the form, the grid displays with a small button on the left most corner, with a + sign. When I click on the + sign, it shows me a link "Tables" and only when I click on the" Tables" link, does the data get displayed in the grid. how do I display the data in the grid while the form loads itself without having to go through the above 2 steps? can someone help?
    Last edited by lis75; Jul 15th, 2004 at 12:04 PM.

  2. #2
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44
    You are doing something incorrect then. How are you binding to the datagrid?
    Jim Webster

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    4
    I am binding the datagrid to the datasource using the code:

    datagrid1.setdatabinding(empDataSet,"")

    where the empDataSet contains the records from the Emp table, which is fetched by the oledbdataAdapter using the querry "select * from emp"

    (I am new to .NET & so I'm not sure if I am doing it the right way!! )

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    VB Code:
    1. 'just replace sqldataadapter to oledbdataadapter
    2. dim ds as new dataset()
    3. ds.tables.add(new datatable("emptable"))
    4. dim da as new Sqldataadapter("select * from emp",cn)
    5. da.fill(ds.tables(0))
    6. datagrid1.datasource = ds.tables(0)

    hope this helps

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    If I recall correctly,

    DataGrid1.DataMember = "NameOfTableSpecifiedWhileFillingUpDataSet"

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    4
    Thanks!
    The code by mar_zim did work fine. I didn't have to set the datagrid.datamember property. But Thanks anyways.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width