|
-
Jul 15th, 2004, 11:55 AM
#1
Thread Starter
New Member
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.
-
Jul 15th, 2004, 12:04 PM
#2
Member
You are doing something incorrect then. How are you binding to the datagrid?
-
Jul 15th, 2004, 12:10 PM
#3
Thread Starter
New Member
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!! )
-
Jul 15th, 2004, 09:00 PM
#4
VB Code:
'just replace sqldataadapter to oledbdataadapter
dim ds as new dataset()
ds.tables.add(new datatable("emptable"))
dim da as new Sqldataadapter("select * from emp",cn)
da.fill(ds.tables(0))
datagrid1.datasource = ds.tables(0)
hope this helps
-
Jul 16th, 2004, 01:38 AM
#5
If I recall correctly,
DataGrid1.DataMember = "NameOfTableSpecifiedWhileFillingUpDataSet"
-
Jul 19th, 2004, 11:57 AM
#6
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|