RE: EUGrid formatting

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jim,

It looks to me like the problem is in the construction of your SQL 
statement:

-- Try and find key in table
cmd = "UPDATE StockIDTable set "&
        "no = '"&number&"'" &
        "   WHERE IDKKey ='" &stockID& "';"

Assuming e.g. number=123 and stockID=789 then this would build a string 
like:

UPDATE StockIDTable set no = '123' WHERE IDKKey ='789';

If the columns you are using are numeric then I don't think that you 
should include the single quotes around the number values i.e. your SQL 
should be:

UPDATE StockIDTable set no = 123 WHERE IDKKey = 789;

I suggest you try modifying your code to something like:

cmd = "UPDATE StockIDTable set " &
        "no = " & sprintf("%0d", number) &
        "   WHERE IDKKey =" & sprintf("%0d", stockID) & ";"

NB I haven't actually tried this!

HTH,

Phil

sixs wrote:
> 
> 
> Phil, I hope this is the code you requested. It is code from Noah 
> converted.
> I haven't put any delete or add functions as yet.
>  I will appreciate any advice.
> Jim
> ============================= code from Noah.exw=============
> ColStock = EGW_AddColumn(Grid, "ID", 50, EGW_LAST, EGW_EDIT, STOCK ),
> ColName = EGW_AddColumn(Grid, "Company", 150, EGW_LAST, EGW_EDIT, NAME 
> ),
> ColDate  = EGW_AddColumn(Grid, "Date", 50, EGW_LAST, EGW_EDIT, DATE ),
> ColNumber = EGW_AddColumn(Grid, "No", 50, EGW_LAST, EGW_EDIT, NUMBER ),
> ColAmount = EGW_AddColumn(Grid, "Amount", 50, EGW_LAST, EGW_EDIT, AMOUNT 
> )
> -- Set grid attributes
> void = EGW_SetGridProperty(Grid, EGW_LINE_COLOR, Black)
> void = EGW_SetGridProperty(Grid, EGW_CELL_BORDER_COLOR, Black)
> void = EGW_SetGridProperty(Grid, EGW_NUMBER_FORMAT, "%0d")
> void = EGW_SetGridProperty(Grid, EGW_HIGHLIGHT_TEXT, EGW_True)
> 
> -- Set column attributes
> void = EGW_SetColumnProperty(Grid, ColStock, EGW_COL_ALIGN, EGW_LEFT)
> void = EGW_SetColumnProperty(Grid, ColName, EGW_COL_ALIGN, EGW_LEFT)
> void = EGW_SetColumnProperty(Grid, ColDate, EGW_COL_ALIGN, EGW_RIGHT )
> void = EGW_SetColumnProperty(Grid, ColNumber, EGW_COL_ALIGN, EGW_RIGHT )
> void = EGW_SetColumnProperty(Grid, ColAmount, EGW_COL_ALIGN, EGW_RIGHT )
> --void = EGW_SetColumnProperty(grid6, grid6col2, EGW_COL_DATATYPE,
> EGW_NUMBER)
> -- Date of Birth column, editable + right aligned
> --coldob = EGW_AddColumn( grid1, "DOB", 100, EGW_LAST, EGW_EDIT, 2 )
> --void   = EGW_SetColumnProperty( grid1, coldob, EGW_COL_ALIGN, 
> EGW_RIGHT )
> --*------------------------------------------------------*
> Noah.e ++++++++++++++++++++++++++++++++++++++
> global function SaveStockData( sequence record )
>  atom recno
>  object newkey, bret
>  sequence db_record
>  trace(2)
>  bret=False
>  -- Set up database record
> -- db_record = EmptyDBRecord
> -- db_record[Stock] = record[Stock]
> -- db_record[NUMBER] = record[NUMBER]
> -- db_record[NOTES] = record[NOTES]
>  stockID = record[STOCK]
>  --amt = record[AMOUNT]
>  number   = record[NUMBER]
> -- number = s2n(snumber)
> -- ""&sprintf("%d", f11)&"," &
>   -- Try and find key in table
>  cmd = "UPDATE StockIDTable set "&
>         "no = '"&number&"'" &
>         "   WHERE IDKKey  ='" &stockID& "';"
>  data = sqlite_get_table(sql_db, cmd)
>  if sqlite_last_err_no != SQLITE_OK then
>    printf(2, "%s = %s\n", {"record","Not a valid stock ID"})
> 
>  end if
>  return bret
> 
> end function
> ----- Original Message ----- 
> From: "Phil Russell" <pg_russell at lineone.net>
> To: <EUforum at topica.com>
> Sent: Friday, November 14, 2003 4:20 PM
> Subject: RE: EUGrid formatting
> 
> 
> > Hi,
> >
> > If you specify a column property of EGW_NUMBER then the value is held
> > internally as an atom, with any formatting only being applied when the
> > cell is displayed i.e. the formatting should not be relevant.
> >
> > To help answer your questiom, could you post the following code:
> >
> > 1. The code you are using to extract the value from the grid.
> > 2. The code you are using to write the value to SQLite.
> >
> > Regards,
> >
> > Phil
> >
> >
> > sixs wrote:
> > > I am using Sqllite with EUGrid and having a problem inserting data from
> > > the Grid to SQLite.I can insert the data, but it stores funny, It is a
> > > number field. SQLite stores dat with single quotes. I am not sure if I
> > > am using the numeric  Grid controls.
> > > I have used these formats I changed the "%-0d" to "%-d". I get a single
> > > digit stored into an Sqlite field.
> > > Jvandal
> > > =============================================
> > > void = EGW_SetColumnProperty(Grid, ColNumber, EGW_COL_NUMFORMAT, "%-d")
> > > void = EGW_SetColumnProperty(Grid, ColAmount, EGW_COL_DATATYPE,
> > > EGW_NUMBER)
<snip>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu