Mesuspects that your 3 character type (in the call to OpenOrCreateDB) is the
problem.  Perhaps if you pad it out to an explicit 32-bit value...

-bob mckenzie, palmsource pdx

-----Original Message-----
From: Salma Saad [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 9:37 AM
To: Palm Developer Forum
Subject: Palm m500 and m505


I have a demo program in which I create a a database on the device and
populate it with dummy data. This code works perfectly on all Palm devices
without expansion slots. On the m505 and m500 the database is created
alright but I get a null handle when I try to insert data. Can I use the
data managers function on the new palms? I'm not looking to use expansion
cards, this is just a demo program with some fake data. Any insight would be
very much appreciated. My code is attached below. The OpenOrCreateDB...
function seems to work fine. I look for errors and none are reported and the
db can be found but in the InitializeInventories.. function the handle for
the new record is null.

#define CreatorName 'InvD'
#define InventoryDBName "InvD-invDBD"
static DmOpenRef inventoryDB;

static void CreateInventory(void)
{
 Boolean created = false;
created = OpenOrCreateDB(&inventoryDB,'inv',InventoryDBName);

 if (created)
  {
      InitializeInventories();
  }
}

static Boolean OpenOrCreateDB(DmOpenRef *dbP, ULong type, char *name)
{
 Err err;
 LocalID id;
 UInt16 numRecs;

 id = DmFindDatabase(0,name);
 if (id != 0)
  {
   *dbP = DmOpenDatabaseByTypeCreator(type, CreatorName, dmModeReadWrite);

   return false;
  }
 else
  {
   DmCreateDatabase(0, name, CreatorName, type, false);
   *dbP = DmOpenDatabaseByTypeCreator(type, CreatorName, dmModeReadWrite);

   return true;
  }

 return true;
}

static void InitializeInventories()
{
 Inventory inv1 = {"foodItems", "John", "01/18/2002"};
 VoidHand h = DmNewRecord(inventoryDB, 0, 1);

 if (h) {
  PackInventory(&inv1, h);
  DmReleaseRecord(inventoryDB, 0, true);
 }

}

Salma Saad
Cascabel Incorporated

Phone:   773.235.1567
Web:     http://www.ecascabel.com
Address: 2007 N Oakley Chicago IL, 60647


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to