Results 1 to 5 of 5

Thread: Access table in DBGrid [Please resolve]

  1. #1

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Access table in DBGrid [Please resolve]

    I use the following code to list all the tables in an mdb file.



    VB Code:
    1. dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
    2. dbConnection.Open()
    3. 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.

  2. #2

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Unhappy

    Pllllllleeeeeeeeaaaaaaaasssssssseeeeee... ITS URGENT
    Microsoft Techie

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This segment doesn't make sense , can you show more code this will help the guys here to offer better help !

  4. #4

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    OK!

    I have imported System.Data.OleDb in my form.

    VB Code:
    1. Friend DBName As String
    2. Friend dbTable As OleDbDataTable
    3. Friend dbConnection As OleDbConnection
    4. DBName = "c:\database\db1.mdb"
    5. dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
    6. dbConnection.Open()
    7. dbTable = dbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, New Object() {Nothing, Nothing, Nothing, "TABLE"})
    8. 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?
    Microsoft Techie

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Add the bolded line to your code and you get only table names .
    VB Code:
    1. Friend DBName As String
    2. Friend dbTable As OleDbDataTable
    3. Friend dbConnection As OleDbConnection
    4. DBName = "c:\database\db1.mdb"
    5. dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")
    6. dbConnection.Open()
    7. dbTable = dbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, New Object() {Nothing, Nothing, Nothing, "TABLE"})
    8. lstTables.DataSource = dbTable
    9. [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
  •  



Click Here to Expand Forum to Full Width