CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Data type mismatch in criteria expression - Employee Tutorial Search

Print topic Send  topic

Author Message
danno

Posts: 15
Posted: 05/15/2008, 8:32 AM

I get this error when I specify a department in a search. Seems to be a data type mismatch, but I can't figure out the cause as the list box passes an Integer and department_id is Long Integer:

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft JET Database Engine<br/><b>Description:</b> Data type mismatch in criteria expression.' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\db_oledb.php:84 Stack trace: #0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\db_oledb.php(84): com->Execute('SELECT COUNT(*)...', false) #1 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\db_adapter.php(124): DB_OLEDB->query('SELECT COUNT(*)...') #2 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\Common.php(315): DB_Adapter->query('SELECT COUNT(*)...') #3 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\Default.php(313): CCGetDBValue('SELECT COUNT(*)...', Object(clsdepartments_employees1DataSource)) #4 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\Default.php(124): clsdepartments_employees1DataSource->Open() #5 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\EmpDir\db_oledb.php on line 84

function query($Query) {
if (!$this->Link_ID)
$this->connect();
if ($this->Debug)
printf("Debug: query = %s<br>\n", $Query);
Line 84 -> $this->Query_ID = $this->Link_ID->Execute($Query, $this->AffectedRows);
if ($this->Link_ID->Errors->Count > 0) {
$Error = $this->Link_ID->Errors->Item($this->Link_ID->Errors->Count-1);
$this->Errno = $Error->NativeError;
$this->Error = $Error->Description;
$this->Errors->addError("Database error: " . $this->Error);
}
return $this->Query_ID;
}

Any help greatly appreciated!

Thx,
Danno
View profile  Send private message
DaveSause

Posts: 14
Posted: 05/15/2008, 10:20 AM

data type error in query expression typically means you've defined a field value as an expression, but theres a data type mismatch when it evaluates, for example:

expr1:iff(x>3,3,"two")

The condition part of the expression can be anything, you're only looking for true/false, but it takes the 3 as numeric and the "two" as text, so that's a missmatch. Also, if x is null, that will probably also give a mismatch, you have to specifically say isnull(x) or val(x)>3 to make sure it evaluates all conditions (null, numeric, text) for x.

The problem is that Access trys to help you, an expression like expr1:"" & x will evaluate regardless if x is null, numeric or text and the result will always be text, so perhaps this works in Access, but not in code charge if you are assuming is text and testing for text.

Hope this helps, Dave
_________________
Dave Sause
View profile  Send private message
danno

Posts: 15
Posted: 05/15/2008, 10:41 AM

The error only happens when I specify a Department (for the Employees Tutorial project). The Department list box is set to 'Control Source Type = Database Column', 'Connection = Employees', 'Data Source Type = Table/View', 'Data Source = Departments', 'Bound Column = Department_ID', 'Text Column = Department_Name', 'Data Type = Integer'. I have not manually coded any of the PHP as I am just learning about it. Still at a loss...

Danno
View profile  Send private message
danno

Posts: 15
Posted: 05/21/2008, 1:58 PM

Quote danno:
The error only happens when I specify a Department (for the Employees Tutorial project). The Department list box is set to 'Control Source Type = Database Column', 'Connection = Employees', 'Data Source Type = Table/View', 'Data Source = Departments', 'Bound Column = Department_ID', 'Text Column = Department_Name', 'Data Type = Integer'. I have not manually coded any of the PHP as I am just learning about it. Still at a loss...

Danno

No one can help me? Is anyone familiar with this demo project? Did you have the same problem after following the (some confusing) directions?

Danno
View profile  Send private message
wkempees


Posts: 1679
Posted: 05/21/2008, 3:53 PM

What database are you using Danno?

I just opened a new project, tab solutions, employees directory.
Project setting:
changed to php 4/5 with templates.
Answered ok to reopen dialog.
Changed publishing setting to reflect my setup.
Connections, Intranet is default, pressed Modify.
The Design settings, I accepted the default
(Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Program Files\CodeChargeStudio4\Examples\Intranet\Intranet.mdb;Persist Security Info=False)
The Server tab I set to reflect my settings:
MySQL, Database:Intranet, Host Localhost and so on.
Of course I previously ran the MySQL_SQL file from the examples.

Then I pressed F9 followed by SHIFT-F7
everything works, even tested advanced search on department Documentation, no problems.

So, it must be in either your database tables being different or the connection string to the Server database is wrong.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
danno

Posts: 15
Posted: 05/22/2008, 8:22 AM

I am using the database supplied by Yes for the example, MS Access via OLEDB. I followed the directions in the Tutorial Manual. I guess I can can transfer the db to MySQL and try it there, but I would still like to find out the cause of the problem as it will be a good learning experience for me.

Danno
View profile  Send private message
wkempees


Posts: 1679
Posted: 05/22/2008, 9:04 AM

So, you are using the MsAcces only.
Copy the MsAcces .mdb to your publishing directory (i.e. httdocs)
And reset your Server part of Connection to ODBC, MsAccess, Localhost and so on.
I automatically assumed you would be using XAMPP as a development environment, sorry.

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
danno

Posts: 15
Posted: 06/10/2008, 7:49 AM

I found out the problem is this SQL statement generated by CCS "SELECT COUNT(*) FROM employees INNER JOIN departments ON employees.department_id = departments.department_id WHERE departments.department_name = 3". The WHERE should be 'departments.department_id = 3". I followed the directions in Page 39 exactly. I fixed the problem by editing the grid's 'Data Source' property's WHERE clause. The tutorial directions need to be fixed and cleaned up! Good learning experience though tracking down the problem.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.