Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding to the non-primary table in the bizobj's dataset
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Binding to the non-primary table in the bizobj's dataset
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01089530
Message ID:
01089530
Vues:
58
I create the following bizobj:
public class boPeople:ABusinessObject
{
   public boPeople()
   {
      this.TableName="People";
   }

   public DataSet GetPeople()
   {
      return this.GetDataSet(
         "CREATE TABLE #Test (cName VARCHAR(10), nAge Int)\r\n"+
         "INSERT INTO #Test (cName,nAge) VALUES ('John', 40)\r\n"+
         "INSERT INTO #Test (cName,nAge) VALUES ('Mel', 20)\r\n"+
         "INSERT INTO #Test (cName,nAge) VALUES ('Suzy', 29)\r\n"+
         "SELECT * FROM #Test\r\n"+
         "DROP TABLE #Test\r\n"+
         "CREATE TABLE #TestPart2 (bSelectAll BIT)\r\n"+
         "INSERT INTO #TestPart2 (bSelectAll) VALUES (1)\r\n"+
         "SELECT * FROM #TestPart2\r\n"+
         "DROP TABLE #TestPart2")
   }
}
After I call GetPeople(), the bizobj's dataset contains two tables: People, and People1, all filled in properly.

I register the bizobj with the form.

I am trying to bind an mmCheckbox to the bSelectAll field in the 2nd datatable. According to the topic "Data Binding Simple Bound Windows Forms Controls" since the 2nd table is not the primary table, I have to put the name of the datatable before the field name.

BindingSource=boPeople
BindingSourceMember=People1.bSelectAll

Since the bSelectAll value is 1, the checkbox should be checked.
I have done this, but the checkbox does not show as checked.

I'm wondering whether this might be as a result of the SQL Data Access object having StateChangeAllTables set to false.

When I step through GetDataSet, I reach a point in GetDataTables, where it gets a list of the datatables:
protected string[] GetDataTables(DataSet ds, string tableName, string databaseKey)
{
   string[] DataTables;

   mmDataAccessBase dao = this.GetDataAccessObject(databaseKey);
   
   if (dao.StateChangeAllTables && ds.Tables.Count > 0)
   {
      DataTables = new string[ds.Tables.Count];
      for(int i=0; i < ds.Tables.Count; i++)
      {
         DataTables[i] = ds.Tables[i].TableName;
      }
   }
   else
   {
      DataTables = new string[] {tableName};
   }
   return DataTables;
}
Since dao.StateChangeAllTables is false, the else branch is followed and the array returned contains only "People" instead of "People" and "People1".

I've even tried breaking the query above into two, and calling the overload GetDataSet(sql,tablename) for each table but only the last called is databound.

Please HELP!
Rick
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform