|
-
Apr 6th, 2003, 12:49 PM
#1
Thread Starter
Hyperactive Member
Jet and .NET
I have this code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim cmd As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\Export.mdb;"
Dim dc As New OleDb.OleDbConnection(cmd)
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM MdseFile", cmd)
Dim ds As New DataSet()
dc.Open()
da.Fill(ds, "MdseFile")
dc.Close()
dc.Dispose()
da.Dispose()
'bind to grid
DataGrid1.DataSource = ds.Tables("ItemMast")
End Sub
and have a datagrid on my form.
This runs (at least no running error) but does not fill out the datagrid and display any data. There is data in the file MDSEFILE.
What am I doing wrong?
-
Apr 6th, 2003, 01:51 PM
#2
Sleep mode
There is data in the file MDSEFILE.
Is this file or table in the database??
I hope it's typing mistake
-
Apr 6th, 2003, 02:24 PM
#3
PowerPoster
You never call the DataBind method of the grid.
After this line:
DataGrid1.DataSource = ds.Tables("ItemMast")
insert:
DataGrid1.DataBind()
-
Apr 6th, 2003, 02:29 PM
#4
Sleep mode
I can bind it without that line though !
-
Apr 6th, 2003, 02:38 PM
#5
Frenzied Member
You never call the DataBind method of the grid.
After this line:
DataGrid1.DataSource = ds.Tables("ItemMast")
insert:
DataGrid1.DataBind()
There is not such a method as DataBind for datagird. At least I am not aware of.
The problem is he is setting the datasource as DataGrid1.DataSource = ds.Tables("ItemMast")
but "ItemMast" is not a table in ds.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 6th, 2003, 02:40 PM
#6
Sleep mode
exactly , it confused me . It might be another table in the same database .
-
Apr 6th, 2003, 03:33 PM
#7
PowerPoster
Sorry, I was thinking of the Web Data Grid.
-
Apr 6th, 2003, 03:38 PM
#8
Thread Starter
Hyperactive Member
Resolved and thanks
Issue resolved .. the line DataGrid1.Databind() was not valid and did not work. It was a matter of dumb typing...
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
|