|
-
Mar 4th, 2004, 09:00 AM
#1
Thread Starter
Fanatic Member
Access table in DBGrid [Please resolve]
I use the following code to list all the tables in an mdb file.
VB Code:
dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
dbConnection.Open()
lstObjects.DataSource = dbTable
The code is working fine. But I dont want to list all the columns (like Table_Catalog, Table_Schema, etc). I just want only 4 cols (Name, Description, Date created and Date modified)
Also, after listing the tables, how to open a selected table from the list in DBGrid? I am finding ADO.Net very much confusing.
Please guide.
Regards
Last edited by pvbangera; Mar 5th, 2004 at 02:29 AM.
-
Mar 5th, 2004, 02:30 AM
#2
Thread Starter
Fanatic Member
Pllllllleeeeeeeeaaaaaaaasssssssseeeeee... ITS URGENT
-
Mar 6th, 2004, 06:32 AM
#3
Sleep mode
This segment doesn't make sense , can you show more code this will help the guys here to offer better help !
-
Mar 8th, 2004, 01:12 AM
#4
Thread Starter
Fanatic Member
OK!
I have imported System.Data.OleDb in my form.
VB Code:
Friend DBName As String
Friend dbTable As OleDbDataTable
Friend dbConnection As OleDbConnection
DBName = "c:\database\db1.mdb"
dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
dbConnection.Open()
dbTable = dbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, New Object() {Nothing, Nothing, Nothing, "TABLE"})
lstTables.DataSource = dbTable
The code is working fine. But I dont want to list all the columns (like Table_Catalog, Table_Schema, etc) in the list box. I just want only 4 cols (Name, Description, Date created and Date modified)
Now, further, I want to open a table in DBGrid when the user double clicks any item from the list box containing list of tables; so that the user can make necessary changes to the table.
Please guide how to proceed?
-
Mar 8th, 2004, 08:08 PM
#5
Sleep mode
Add the bolded line to your code and you get only table names .
VB Code:
Friend DBName As String
Friend dbTable As OleDbDataTable
Friend dbConnection As OleDbConnection
DBName = "c:\database\db1.mdb"
dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
dbConnection.Open()
dbTable = dbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, New Object() {Nothing, Nothing, Nothing, "TABLE"})
lstTables.DataSource = dbTable
[B]lstTables.DisplayMember = "TABLE_NAME"[/B]
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
|