[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nsbasic-palm
Subject:    RE: [nsbasic-palm] dim db ... arguments for bound grid
From:       "Carmine Castiglia" <ccastiglia () infosystemspro ! com>
Date:       2006-08-31 22:02:04
Message-ID: 015601c6cd49$1ad3c270$6500a8c0 () Dads
[Download RAW message or body]

Dim theRecord as DbRecType
    Dim db as Database "TestDb", theRecord, DbRecType 
 
The online help for the "Dim" command says:
 
DIM varName AS DATABASE dbName, dbRec, dbLayout [, key]
 
"If we are declaring a database for use in a grid. VarName is the name
of the variable. DbName is the name of the database on the Palm OS
device. DbRec is a global variable which will be created to contain the
contents of the current record of the database. It should not be
dimensioned already. DbLayout is the layout of the record: it should
already be defined using a TYPE statement. Key is an optional variable
that must already be dimensioned: it is the key that is used for the
dbName database. This form is only used to define Varname  when used as
the first argument of a BindToDataBase method for a Grid control. "
 
Note the part about DbRec: "DbRec is a global variable which will be
created to contain the contents of the current record of the database.
It should not be dimensioned already"
 
This may (or may not!) be your problem.
 
  Carmine
 
 

-----Original Message-----
From: nsbasic-palm@yahoogroups.com [mailto:nsbasic-palm@yahoogroups.com]
On Behalf Of Steve Chabra
Sent: Thursday, August 31, 2006 3:50 PM
To: nsbasic-palm@yahoogroups.com
Subject: [nsbasic-palm] dim db ... arguments for bound grid



i'm getting a strange error meessage from the compiler (v. 5.0.5),
"Error...Database name already defined elsewhere", trying to bind a
grid to a database.

here is a short example that i can't get to compile. it has one form
called "Form1" (a.k.a. "Form1003"), that has a grid named "grid", set
up with 10 visible rows, 2 columns, no scrollbar.

========================

Sub Project_Startup()

Type DbRecType
Key as Integer
Data as String
End Type

Global gDbRec as DbRecType

'============================
' app starts here

Dim res as Integer
Dim ctr as Integer
Dim db as Database

' be sure to hard reset simulator each time this is run
' so that TestDb is created each time.

res = DbCreate (db, "TestDb", 0, "XXXX")
If res <> 0 Then
MsgBox "Create TestDb failed with " + str (res)
Exit Sub
End If

res = DbOpen (db, "TestDb", 0)
If res <> 0 Then
MsgBox "Open TestDB failed with " + str (res)
Exit Sub
End If

' write 10 records.
For ctr = 1 to 10
gDbRec.Key = ctr
gDbRec.Data = "This is record # " + str (ctr)
res = DbInsert (db, gDbRec.Key, gDbRec)
If res <> 0 Then
MsgBox "Insert TestDb failed (" + str (ctr) + ")."
Exit Sub
End If
Next

res = DbClose (db)
If res <> 0 Then
MsgBox "Close TestDb failed."
Exit Sub
End If

NextForm "Form1", CLEAR

End Sub

========================

Sub Form1003_Before()
' load the grid from the database TestDb.

Dim res as Integer
Dim theRecord as DbRecType

' the next line causes an "Error...Database name already
' defined elsewhere" error from the compiler, highlighting
' "theRecord"
Dim db as Database "TestDb", theRecord, DbRecType

grid.BindToDatabase (db, theRecord.Key, theRecord.Data)

End Sub

========================
somehow, none of the documentation i'be seen for the grid explains
what the second argument should be. i thought that an instance of the
data record made sense, but apparently not. what am i missing? many
thanks.



 


[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<!-- Network content -->
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY style="BACKGROUND-COLOR: #ffffff">


<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006><FONT 
face="Times New Roman" color=#000000>&nbsp;&nbsp;&nbsp; Dim theRecord as 
DbRecType</FONT><BR></SPAN></FONT><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006><FONT face="Times New Roman" 
color=#000000>&nbsp;&nbsp;&nbsp; Dim db as Database "TestDb", theRecord, 
DbRecType </FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>The online 
help for the "Dim" command says:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>DIM varName 
AS DATABASE dbName, dbRec, dbLayout [, key]</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>"If we are 
declaring a database for use in a grid. VarName is the name of the variable. 
DbName is the name of the database on the Palm OS device. DbRec is a global 
variable which will be created to contain the contents of the current record of 
the database. It should not be dimensioned already. DbLayout is the layout of 
the record: it should already be defined using a TYPE statement. Key is an 
optional variable that must already be dimensioned: it is the key that is used 
for the dbName database. This form is only used to define Varname&nbsp; when 
used as the first argument of a BindToDataBase method for a Grid control. 
"</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>Note the part 
about DbRec: "DbRec is a global variable which will be created to contain the 
contents of the current record of the database. It should not be dimensioned 
already"</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>This may (or 
may not!) be your problem.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN class=569315421-31082006>&nbsp; 
Carmine</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff><SPAN 
class=569315421-31082006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff></FONT>&nbsp;</DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT 
  face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> 
  nsbasic-palm@yahoogroups.com [mailto:nsbasic-palm@yahoogroups.com] <B>On 
  Behalf Of </B>Steve Chabra<BR><B>Sent:</B> Thursday, August 31, 2006 3:50 
  PM<BR><B>To:</B> nsbasic-palm@yahoogroups.com<BR><B>Subject:</B> 
  [nsbasic-palm] dim db ... arguments for bound grid<BR><BR></FONT></DIV>
  <DIV id=ygrp-text>
  <P>i'm getting a strange error meessage from the compiler (v. 
  5.0.5),<BR>"Error...Database name already defined elsewhere", trying to bind 
  a<BR>grid to a database.<BR><BR>here is a short example that i can't get to 
  compile. it has one form<BR>called "Form1" (a.k.a. "Form1003"), that has a 
  grid named "grid", set<BR>up with 10 visible rows, 2 columns, no 
  scrollbar.<BR><BR>============<WBR>=========<WBR>===<BR><BR>Sub 
  Project_Startup(<WBR>)<BR><BR>Type DbRecType<BR>Key as Integer<BR>Data as 
  String<BR>End Type<BR><BR>Global gDbRec as 
  DbRecType<BR><BR>'===========<WBR>=========<WBR>========<BR>' app starts 
  here<BR><BR>Dim res as Integer<BR>Dim ctr as Integer<BR>Dim db as 
  Database<BR><BR>' be sure to hard reset simulator each time this is run<BR>' 
  so that TestDb is created each time.<BR><BR>res = DbCreate (db, "TestDb", 0, 
  "XXXX")<BR>If res &lt;&gt; 0 Then<BR>MsgBox "Create TestDb failed with " + str 
  (res)<BR>Exit Sub<BR>End If<BR><BR>res = DbOpen (db, "TestDb", 0)<BR>If res 
  &lt;&gt; 0 Then<BR>MsgBox "Open TestDB failed with " + str (res)<BR>Exit 
  Sub<BR>End If<BR><BR>' write 10 records.<BR>For ctr = 1 to 10<BR>gDbRec.Key = 
  ctr<BR>gDbRec.Data = "This is record # " + str (ctr)<BR>res = DbInsert (db, 
  gDbRec.Key, gDbRec)<BR>If res &lt;&gt; 0 Then<BR>MsgBox "Insert TestDb failed 
  (" + str (ctr) + ")."<BR>Exit Sub<BR>End If<BR>Next<BR><BR>res = DbClose 
  (db)<BR>If res &lt;&gt; 0 Then<BR>MsgBox "Close TestDb failed."<BR>Exit 
  Sub<BR>End If<BR><BR>NextForm "Form1", CLEAR<BR><BR>End 
  Sub<BR><BR>============<WBR>=========<WBR>===<BR><BR>Sub 
  Form1003_Before(<WBR>)<BR>' load the grid from the database TestDb.<BR><BR>Dim 
  res as Integer<BR>Dim theRecord as DbRecType<BR><BR>' the next line causes an 
  "Error...Database name already<BR>' defined elsewhere" error from the 
  compiler, highlighting<BR>' "theRecord"<BR>Dim db as Database "TestDb", 
  theRecord, DbRecType<BR><BR>grid.BindToDatabase (db, theRecord.Key, 
  theRecord.Data)<BR><BR>End 
  Sub<BR><BR>============<WBR>=========<WBR>===<BR>somehow, none of the 
  documentation i'be seen for the grid explains<BR>what the second argument 
  should be. i thought that an instance of the<BR>data record made sense, but 
  apparently not. what am i missing? many<BR>thanks.<BR><BR></P></DIV><!--End group \
email --></BLOCKQUOTE> <span width="1" style="color: white;"/>__._,_.___</span>

<!-- |**|begin egp html banner|**| -->

<br><br>
<tt>
<BR>
Complete Searchable Archive:<BR>
 <a href="http://marc.theaimsgroup.com/?l=nsbasic-palm&r=1&w=2">http://marc.theaimsgroup.com/?l=nsbasic-palm&amp;r=1&amp;w=2</a><BR>
 <BR>
Shortcut URL to this page:<BR>
 <a href="http://groups.yahoo.com/group/nsbasic-palm">http://groups.yahoo.com/group/nsbasic-palm</a> \
</tt> <br><br>

<!-- |**|end egp html banner|**| -->



<!-- |**|begin egp html banner|**| -->

  <img src="http://geo.yahoo.com/serv?s=97476590&amp;grpId=2019755&amp;grpspId=1600006765&amp;msgId=52358&amp;stime=1157061811" \
width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->

  

<!-- |**|begin egp html banner|**| -->

<br>
  <div style="text-align:center; color:#909090; width:500px;">
  <hr style="border-bottom:1px; width:500px; text-align:left;">
  <tt>YAHOO! GROUPS LINKS</tt>
</div>
<br>
<ul>
  <tt><li type=square>&nbsp;Visit your group "<a \
href="http://groups.yahoo.com/group/nsbasic-palm">nsbasic-palm</a>" on the \
web.<br>&nbsp;</tt>  <tt><li type=square>&nbsp;To unsubscribe from this group, send \
an email to:<br>&nbsp;<a \
href="mailto:nsbasic-palm-unsubscribe@yahoogroups.com?subject=Unsubscribe">nsbasic-palm-unsubscribe@yahoogroups.com</a><br>&nbsp;</tt>
  <tt><li type=square>&nbsp;Your use of Yahoo! Groups is subject to the <a \
href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.</tt> </ul>
<br>
<div style="text-align:center; color:#909090; width:500px;">
  <hr style="border-bottom:1px; width:500px; text-align:left;">
</div>
<br>

<!-- |**|end egp html banner|**| -->


<span  style="color: white;"/>__,_._,___</span>
</BODY></HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic