CJ Wiley
|
Posted: 01/19/2004, 7:19 AM |
|
How do I handle DATE FIELDS? I receiving a 'data type mismatch' error.
|
|
|
peterr
Posts: 5971
|
Posted: 01/19/2004, 12:35 PM |
|
What field type are you using in FoxPro - date or datetime?
What Date Format have you specified in CCS Connection (Server)?
Are you using ODBC?
Where/how do you get this error? When executing a search, or just displaying a grid or record?
For now please see: http://support.microsoft.com/default.aspx?scid=http://s...&NoWebContent=1
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
lvalverdeb
Posts: 299
|
Posted: 01/20/2004, 6:51 AM |
|
I posted a php workaround at:
http://forums.codecharge.com/posts.php?post_id=25642
It works -at least in my computer . The code modifies the SQL statement generated by CCS for date fields to use foxpro's format i.e {^yyyy-mm-dd} and should be run from the BeforeExecuteInsert and/or BeforeExecuteUpdate.
For example:
$newSQL = SQLToFox($YourForm->ds->SQL,$YourForm,$YourDateField);
$YourForm->ds->SQL = $newSQL;
I hope it works for you.
Regards
Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
|
|
CJ Wiley
|
Posted: 01/20/2004, 8:09 AM |
|
Peter R,
My FoxPro Field is DATE.
My Date format is set to mm/dd/yyyy.
Yes, I am using ODBC.
I receive the error when I try to update.
Luis,
Please, bear with me. I'm just started with this and I'm not totally understanding what you have written. :)
** $newSQL = SQLToFox($YourForm->ds->SQL,$YourForm,$YourDateField);
** $YourForm->ds->SQL = $newSQL;
My form is labcal_maint. My date field is lddate.
I assume I have to create events BeforeExecuteInsert and/or BeforeExecuteUpdate with the following code in it:
$newSQL = SQLToFox(labcal->ds->SQL,labcal,lddate);
labcal->ds->SQL = $newSQL;
Thanks to you both for your help!
CJ
|
|
|
lvalverdeb
Posts: 299
|
Posted: 01/20/2004, 10:02 AM |
|
Hi CJ,
No problem at all.
The BeforeExecuteInsert and the BeforeExecuteUpdate are standard CCS Record Form events. That is, forms used for inserting and updating data. In order to view these events, select the form and go to the Events tab of the properties sheet. From your message, I gather you are using a Record Form.
If your form is called labcal_maint and your date field is lddate, then the code would look like this:
global $labcal_maint; // this is automatically generated by CCS where adding code to an event.
$newSQL = SQLToFox($labcal_maint->ds->SQL,$labcal_maint,$labcal_maint->lddate); // creates a 'foxpro-friendly' SQL statement.
$labcal_maint->ds->SQL = $newSQL; // assigns the new SQL Statement to the form's datasource
I hope this makes more sense.
Luis
The above assumes that you've placed (or included) the SQLToFox function in the common.php library file of your project. In this manner, you're able to call it from any file.
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
|
|
CJ Wiley
|
Posted: 01/21/2004, 8:42 AM |
|
Luis,
I've looked all over and searched and obviously overlooking the instructions on how to add a function in the Common.asp. Which I guess wouldn't work for the purpose of what you have shown me.
How do I add a function in the Common files?
Is there a solution for this DATE problem for ASP?
Which is better ASP or PHP?
Thank you very much for your help!
CJ
|
|
|
lvalverdeb
Posts: 299
|
Posted: 01/21/2004, 9:51 AM |
|
Hi CJ,
Unfortunately, I don't write ASP code anymore. I can't promise anything but I'll try to post an ASP version sometime soon.
With respect as to how to add a function to the common files, I use two different approaches.
1) Open the Common.php file located in the project directory and add the code at the end of the file save it and that's pretty much it!
or 2) Create your own library of functions, place it in the project directory and "include" them in the Common.php or Common.asp file. You do this by simply writing the following line right after the main "includes" at the beginning of the common file:
include(RelativePath . "/yourFunctions.php"); // my functions
after you've done this, the first part of the common file should look like this:
//Include Files @0-6CA7C540
include(RelativePath . "/Classes.php"); // default CCS
include(RelativePath . "/db_mysql.php");//default CCS
include(RelativePath . "/yourFunctions.php"); // my functions
//End Include Files
In asp the code would look like this:
%>
<!-- #INCLUDE FILE="Adovbs.asp" --> ' Default CCS
<!-- #INCLUDE FILE="Classes.asp" --> ' Default CCS
<!-- #INCLUDE FILE="yourFuncs.asp" --> ' my functions
<%
I personally prefer solution 2. If you add the SQLToFox function to the common.php file using either method and add the code to the BeforeExecuteInsert and BeforeExecuteUpdate, your problem with foxpro should be fixed.
Which is better PHP or ASP? I haven't an educated answer to this. I believe it is a matter of what you feel comfortable with. I find writing php code very convenient in terms of syntax, structure plus it's also open source. Other people on the forums may want to take this discussion up further.
Regards
Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
|
|
CJ Wiley
|
Posted: 01/22/2004, 3:26 PM |
|
Luis,
Thank you again! You have been very helpful.
If you are able to post an ASP version I would be grateful, but don't stress yourself.
Since this seems to be a common problem maybe Code Charge programmers could do it (hint, hint, to any CodeCharge employees passing by).
Except for the DATE trouble this product looks good.
CJ
|
|
|
peterr
Posts: 5971
|
Posted: 01/23/2004, 12:05 PM |
|
Hello,
It indeed seems that FoxPro utilizes unusual date delimiters. Our engineers propose this non-language specific solution:
Please go to the following folder on your computer:
C:\Program Files\CodeChargeStudio\Components\Databases
(or equivalent folder if you installed CCS elsewhere)
Then make a copy of one of the database definitions that already works best for you, I'm assuming in this case it would be "ANSI.xml", and name the new file as "Foxpro.xml".
Then edit the file and specify the Date delimiter fields that are used by FoxPro. For example:
dateLeftDelim="{^"
dateRightDelim="}"
Then when you restart CCS you should be able to select FoxPro as your database type.
Hope this helps.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
CJ Wiley
|
Posted: 01/23/2004, 6:39 PM |
|
Peter R.,
I did as you suggested.
I went to C:\Program Files\CodeChargeStudio\Components\Databases.
Made a copy of ANSI and named it FoxPro.
Then I made the following changes:
dateLeftDelim="{^"
dateRightDelim="}"
Then I restarted CodeCharge Studio.
I went to my database connection to change the database.
FoxPro doesn't show up.
What did I do wrong?
Thanks!
CJ
|
|
|
CJ Wiley
|
Posted: 01/23/2004, 6:51 PM |
|
Never mind. I forgot to change the internal name.
|
|
|
CJ Wiley
|
Posted: 01/23/2004, 7:01 PM |
|
Unfortunately, I still recieve a Data Type Mismatch.
|
|
|
peterr
Posts: 5971
|
Posted: 01/23/2004, 8:02 PM |
|
CJ,
Unfortunately I don't have a FoxPro database to "play with", but possibly you could send me some sample FoxPro database file and a sample CCS project (or a page) and I'll research this issue.
Please submit your question to my attention at http://support.codecharge.com , then attach the zipped file(s) (there will be an email shown to send the attachments to after submitting the request).
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
|