Results 1 to 12 of 12

Thread: Load all db tables in treeview??[Resolved]

Threaded View

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Load all db tables in treeview??[Resolved]

    I couldn't figure out how to do this ? I have only VB.NET version ! I've been trying to convert it for a while but to no avail . anyone show me how plz ?

    VB Code:
    1. 'TreeView
    2. Public Overloads Shared Sub LoadTables(ByVal TreView As TreeView)
    3.                 OpenDB.OpenDB()
    4.                 Dim Tables As DataTable = MyConnection.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, _
    5.                 New Object() {Nothing, Nothing, Nothing, "TABLE"})
    6.                
    7.                 CloseDB.CloseDB()
    8.                 If Tables.Rows.Count > 0 Then
    9.                     TreView.BeginUpdate()
    10.                     'add tables as child nodes
    11.                     Dim dr As DataRow
    12.                     For Each dr In Tables.Rows
    13.                         'you can add icons here if you want
    14.                         TreView.Nodes.Add(New TreeNode(dr("TABLE_NAME")))
    15.                     Next
    16.                     TreView.EndUpdate()
    17.                 End If
    18.                 Tables = Nothing
    19.             End Sub

    C#
    Code:
    //TreeView
    			public static void LoadTables (System.Windows.Forms.TreeView TreView) 
    			{
    			OpenDB.OpenDB1() ;
    			DataTable Tables = MyConnection().GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,new object[]{null,null,null,"TABLE"});
    			CloseDB.CloseDB1();
    				
    				if (Tables.Rows.Count > 0 ){
    			TreView.BeginUpdate();
          
    					foreach (DataRow dr in Tables.Rows ) {
    TreView.Nodes.Add(new TreeNode (dr(("TABLE_NAME"))));
     TreView.EndUpdate ();
    					}
    					Tables=null;
    			
    				}		
    
    			}
    This code keeps throwing an error says :
    Class1.cs(72): 'dr' denotes a 'variable' where a 'method' was expected
    I tried all possible ways but I don't get it to work ? Is my code correct ??
    btw , I can load tables in listbox , combobox , checkedlistbox !

    Thanks
    Last edited by Pirate; Mar 19th, 2003 at 10:11 AM.

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