Index: trunk/FACT++/src/root2sql.cc
===================================================================
--- trunk/FACT++/src/root2sql.cc	(revision 19807)
+++ trunk/FACT++/src/root2sql.cc	(revision 19808)
@@ -412,5 +412,7 @@
     while ((o=Next()))
     {
-        TLeaf *L = T->GetLeaf(o->GetName());
+        TLeaf *L = dynamic_cast<TLeaf*>(o);//c.GetLeaf(o->GetName());
+        if (!L)
+            continue;
 
         if (verbose>2)
@@ -495,18 +497,29 @@
     UInt_t datatype = 0;
     const bool has_datatype = T->SetBranchAddress("DataType.fVal", &datatype) >= 0;
-
-    // Setiing up branch status (must be after all SetBranchAddress)
+    if (has_datatype && verbose>0)
+        cout << "Rows with DataType.fVal!=1 will be skipped." << endl;
+
+    // -------------------------------------------------------------------------
+    // Setting up branch status (must be after all SetBranchAddress)
     T->SetBranchStatus("*", 0);
-    for (auto c=vec.cbegin(); c!=vec.cend(); c++)
-        if (c->type!=FileEntry::kConst)
-            T->SetBranchStatus(c->branch.c_str(), 1);
-
-    if (has_datatype)
-    {
-        T->SetBranchStatus("DataType.fVal", 1);
-        if (verbose>0)
-            cout << "Rows with DataType.fVal!=1 will be skipped." << endl;
-    }
-
+
+    Next.Reset();
+    while ((o=Next()))
+    {
+        const TLeaf *L = dynamic_cast<TLeaf*>(o);//c.GetLeaf(o->GetName());
+        if (!L)
+            continue;
+
+        const TBranch *B = L->GetBranch();
+        if (!B)
+            continue;
+
+        if (!B->GetAddress())
+            continue;
+
+        c.SetBranchStatus(B->GetName(), 1);
+        if (verbose>2)
+            cout << "Enable Branch: " << B->GetName() << endl;
+    }
 
     // -------------------------------------------------------------------------
