telmiger
Posts: 61
|
| Posted: 11/29/2004, 9:01 PM |
|
I have an editable grid and added a checkbox to each record.
After the editable grid is submitted I would like to copy the records on which the checkbox is marked into a different table. (Only the records that show up in the editable grid and the checkbox is marked)
I am having problems getting my Where clause to work.
global $project_charges;
global $expenses;
global $times;
$DBcns = new clsDBcns;
$DBcns->query("Insert into times1 (time_id, project_id, employee_id, date, time, code, comments) select time_id, project_id, employee_id, date, time, code, comments from times WHERE"
. $times->invoice->ds->Where "= invoice ==1");
Invoice is my checkbox value 1 for "checked"
I have a syntax errror but I am not sure what I am doing wrong. I tried all night with different variation of the where clause but without anysuccess.
Tony Elmiger
|
 |
 |
mrachow
Posts: 509
|
| Posted: 11/30/2004, 1:48 AM |
|
Please "print out" (echo) your SQL statement and I suppose you will see that it is syntactically not correct.
_________________
Best regards,
Michael |
 |
 |
Damian Hupfeld
|
| Posted: 11/30/2004, 3:05 AM |
|
You could also leave th erecords in the original database and just use query
those records that have a value in teh checkbox?
regards
Damian Hupfeld http://www.itng.com.au/services.php
"mrachow" <mrachow@forum.codecharge> wrote in message
news:541ac4208d4fa8@news.codecharge.com...
> Please "print out" (echo) your SQL statement and I suppose you will see
> that it
> is syntactically not correct.
> _________________
> Regards,
> Michael
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
telmiger
Posts: 61
|
| Posted: 01/03/2005, 7:30 PM |
|
Thanks to a post I found from peterr I have my custom code almost figured out. It works perfect with all integer values but I have a problem with inserting the date and a memo field.
The custom code I use in the Before Execute event of my editable grid.
global $times;
global $DBcns;
$EmpProjectConn = null;
$GetLastInsKey = 0;
$EmpProjectConn = new clsDBcns();
$GetLastInsKey = CCDLookup("max(project_charge_id)", "project_charges", "", $DBcns);
if ($times->invoice->GetValue() == 1)
{
$DBcns->query ("Insert into invoiced (time_id,employee_id,qty,rate,total,charge_id,date_1,comments,project_id) VALUES ("
.$times->time_id->GetValue() .","
.$times->employee_id->GetValue() .","
.$times->time1->GetValue() .","
.$times->rate1->GetValue() .","
.$times->subtotal1->GetValue() .","
.$EmpProjectConn->ToSQL($GetLastInsKey, ccsInteger) . ","
.$times->date1->GetValue() ."," // *** 1
.$times->comments1->GetValue() ."," // *** 2
.$times->project_id->GetValue() .")");
}
***1 Gives me the following error. Reads the value from a hidden date field.
Database error: Invalid SQL: Insert into invoiced (time_id,employee_id,qty,rate,total,charge_id,date_1,project_id) VALUES (315,4,3,225,675,95,Array,38)
MySQL Error: 1054 (Unknown column 'Array' in 'field list') This is generated b the date
*** 2 Reads from a hidden memo field and is suppose insert the data into a blob field
Database error: Invalid SQL: Insert into invoiced (time_id,employee_id,qty,rate,total,charge_id,comments,project_id) VALUES (315,4,3,225,675,95,Array,,38)
MySQL Error: 1064 (You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '38)' at line 1)
Is there another syntax that I have to do use with date or text fields? The other fields inserted perfectly into the new table.
Tony Elmiger
|
 |
 |
|