Welcome Guest, Not a member yet? Register   Sign In
Database Error Number 7405
#1

[eluser]whobutsb[/eluser]
Hello All

I'm running into some issues with querying my MSSQL Database. I have a DB that is pulling a list of employees from Active Directory into a View. Everything works fine with the view and I have used it in the past but not with CI.

I now have a CI Model that is supposed to search the table using the WHERE LIKE statement.

My Model looks like this:

Code:
class NHCEmployee_model extends Model{
    
    var $NHCUsers;

    function NHCEmployee_model(){
        parent::Model();
        $this->NHCUsers = $this->load->database('NHCUsers', TRUE);
    }
    
    
    function search_employees($displayname){
        $this->NHCUsers->select('displayname, username');
        $this->NHCUsers->like('displayname', $displayname);
        $query = $this->NHCUsers->get('tblNHCEmployees');
        return $query->result();
    }
}

I have the the Database all set up perfectly in CI with the correct User/Pass. But whenever I run the query I get this error message:

Code:
<h1>A Database Error Occurred</h1>
        <p>Error Number: 7405</p><p></p><p>SELECT displayname, username
FROM tblNHCEmployees
WHERE  displayname  LIKE '%ste%'</p>

Is there any way to debug these Error Numbers? When I run this query in MSSQL Management Query it performs fine.

Thank you for the help!
#2

[eluser]bena[/eluser]
Hi,

This is just a suggestion, but maybe give the select function an array as opposed to a string? I'm not sure if it even accepts an array but it may be worth a shot!

Code:
# Change:
$this->NHCUsers->select('displayname, username');

# To:
$this->NHCUsers->select(array('displayname','username'));

Hope you fix it.

Regards,
Ben
#3

[eluser]whobutsb[/eluser]
Hi Ben,
Thanks for the tip. I tried it with an array and received the same results. I have used both strings and arrays in my select statements in the past and they have both worked out just fine.

But I'm guessing there is something else that is happening.

Thanks for the help anyways!
Steve
#4

[eluser]John_Betong[/eluser]
&nbsp;
From: http://ellislab.com/codeigniter/user-gui...lpers.html
&nbsp;
Try using this function: $this->db->last_query();, copy the result and paste it to PhpMyAdmin()
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB