Page 1 of 1

Adding new field problem

PostPosted: Wed Mar 23, 2016 2:20 pm
by KenHos
I created a database. Created a table. Latter I needed to add another field. It says it's there but no data can be entered. I can see it in the field. But when I close out and run the program again, it's not there. What? Please help! Sorry if this is simple and I'm just missing it. Old dbase programmer just learning!

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 7:40 am
by Rasl
What kind of database are you using?
MSSQL, MySQL , SQLite , Access, dbf

Re: what kind

PostPosted: Thu Mar 24, 2016 10:02 am
by KenHos
access

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 1:26 pm
by Gaev
KenHos:

Your descriptions are not very clear.

It says it's there

Please show us the code you are using e.g. something like ...
Code: Select all
dbpShowErrors "Yes"

dbpOpenAccessDatabase "myDB" "etc. etc." ""
dbpOpenTable "myDB" "myTable" ""

dbpGetFieldDefs "myDB" "myTable" "[#13]" "[TextEntry1]"
dbpAddfield "myDB" "myTable" "myNewFieldName" "myNewFieldDefinition"
dbpGetFieldDefs "myDB" "myTable" "[#13]" "[TextEntry2]"
AlertBox "RecordCount" "[myDB.myTable.$RecNum]"

... and post the results you are seeing in TextEntry1 and TextEntry2 ... as well as the current record number returned by the AlertBox.

but no data can be entered.

Did you try something like ...
Code: Select all
SetVar "[myDB.myTable.myNewFieldName]" "qwerty"

... or were you trying to use the Grid ?

I can see it in the field.

a) Where can you see it ? ... in the Grid ?
b) what can you see ? ... the column for the new field in the Grid ?

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 5:58 pm
by KenHos
Using grid, but Not in the grid!
There are nine entry boxes or field boxes. Eight work One doesn't. Same code, different field names. Was using six added three and two of three added fine. One didn't.

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 6:01 pm
by KenHos
SetVar "[mScr]" "[worship.words.blank]"
FileExists "[PubDir]Worship.exe" "[mRESULT]"
If "[mRESULT]" "<" ""
dbpCreateAccessDatabase "worship" "Password=;Encrypted=No"
dbpOpenAccessDatabase "worship" "worship" ""
dbpCreateTable "worship" "words" "list Boolean;song String(50);verse1 String(500);verse2 String(500);verse3 String(500);verse4 String(500);verse5 String(500);verse6 String(500);chorus String (500);chorus2 String(499);bridge String(499);font Char(2);blank Char(8)"
dbpOpenTable "worship" "words" ""
Else
dbpOpenAccessDatabase "worship" "worship" ""
dbpOpenTable "worship" "words" ""
Endif

.....
dbpSetAutoEdit "worship" "words" "Yes"
dbpShowGrid "worship" "words" "b1"
dbpSetColumnOrder "worship" "words" "list;song"
dbpSetColumnWidths "worship" "words" ""
dbpSetGridProperties "worship" "words" "Font=Arial,11,Bold,ANSI_CHARSET;RowHeight=24;AllowRowResize=No;AllowColumnResize=No;AllowColumnSort=Yes;ConfirmDelete=No;ReadOnly=No;EditOnly=No;RowSelect=Yes;ShowScrollBars=Vertical;ShowNavigationBar=No;GetDefaultValues=No;OnDoubleClick=test;OnRightClick=test2"
dbpSetFieldProperties "worship" "words" "list" "PickList= ;DropDownRows=7"
dbpSetFieldProperties "worship" "words" "song" "ColumnWidth=210"
......
dbpSort "worship" "words" "song=ASC"

This a lyrics presentation program for my Church. It work great until I added 3 new fields

dbpCreateTable "worship" "words" "list Boolean;song String(50);verse1 String(500);verse2 String(500);verse3 String(500);verse4 String(500);verse5 String(500);verse6 String(500);chorus String(500);chorus2 String(499);bridge String(499);font Char(2);blank Char(8)"

dbpOpenTable "worship" "words" "" Verse6, chorus2, bridge are new. bridge does not work.

Remember, I am old School dbase\Clipper programmer. In my day, I was one of the best. 38 years ago! Awe such changes! Walk away and have been pastoring a Baptist Church for 29 years. Just getting back in the last two years.

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 6:45 pm
by Gaev
KenHos:

I am guessing that you did not add field(s) to an existing Database using the dbpAddField command (as I imagined) ... but recreated the database from scratch (adding fields to the dbpCreateTable command) ... and encountered problems when the additional fields caused you to exceed the limit for the maximum record size in an Access Table.

Over here ... http://webcheatsheet.com/sql/access_specification.php ... you will see that even when using MS Access 2007 or MS Access 2003, the limit is 4,000 bytes (for earlier versions, it is 2,048).

The number of bytes in your dbpCreateTable is about 4,560 !!!

However, all is not lost ...

a) the limit for records excludes Memo fields.

b) you have a number of String fields each with 500 characters (which exceeds the limit in Access of 255 characters)

... so try again with all your String(500) character fields defined as Memo (each of which can be as large as 65,535 characters).

Re: Adding new field problem

PostPosted: Thu Mar 24, 2016 10:05 pm
by KenHos
Thanks Gaev! That work great. So Simple, unless you don't know! Thanks