• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Database Error Occurred

#1
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'currInstl + 1' to data type int.

SELECT "custNo", "custName", "totalInstal", "InstallAmnt" FROM "fund" WHERE "status" = 'A' AND "branch" = 16 AND "totalInstal" > 'currInstl + 1' ORDER BY "custName" ASC



Ref (Sql Query works well)
=================
select custNo, custName, totalInstal, InstallAmnt from fund
where status='A' and branch=16 and totalInstal> currInstl+ 1
order by custName;

but not to works in codeigniter..Please help me
Reply

#2
@Mohamed,
can you send your PHP code with your sql request?

Perhaps, a problem with your quotes: 'currInstl + 1'
Reply

#3
(03-30-2019, 02:54 AM)hc-innov Wrote: @Mohamed,
can you send your PHP code with your sql request?

Perhaps, a problem with your quotes:  'currInstl + 1'

public function getFund()
{
return $this->db->select('custNo, custName, totalInstal, InstallAmnt')
->from('fund')
->where('status', 'A')
->where('branch', 16)
->where('totalInstal >', 'currInstl + 1')
->order_by('custName', 'asc')
->get()
->result_array();
}
Reply

#4
You can try this

PHP Code:
public function getFund()
{
return 
$this->db->select('custNo, custName, totalInstal, InstallAmnt')
->
from('fund')
->
where('status''A')
->
where('branch'16)
->
where('totalInstal >''currInstl + 1',false)
->
order_by('custName''asc')
->
get()
->
result_array();

Note the false in where clause for totalInstall <=>The field is not protected (no quote)
Reply

#5
(03-30-2019, 11:04 AM)hc-innov Wrote: You can try this

PHP Code:
public function getFund()
{
return 
$this->db->select('custNo, custName, totalInstal, InstallAmnt')
->
from('fund')
->
where('status''A')
->
where('branch'16)
->
where('totalInstal >''currInstl + 1',false)
->
order_by('custName''asc')
->
get()
->
result_array();

Note the false in where clause for totalInstall <=>The field is not protected (no quote)

Thank you so much it's working.. Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.