Welcome Guest, Not a member yet? Register   Sign In
Conflicting Libraries and Helpers?
#1

[eluser]whobutsb[/eluser]
I have been noticing some weird behavior with using libraries, behaviors and datebases that are not the default.

I'm working on building a Intranet site for my company. I have setup a couple of libraries:
One requests the business units and builds a drop down menu with their names and business unit IDs, I can call it by using
Code:
$this->businessunit->businessunit_dropdown('dropdown_name');
. I have setup helpers for some of the library functions to make calling some of the functions quicker like:
Code:
businessunit_dropdown('dropdown_name');


I also have a library that turns a users username into their full displayname. I can use something like this to get the displayname
Code:
displayname(username());

The Business Units Library queries a MSSQL Database that is not the default and the Users library calls Active Directory. I have some Memcaching so I don't hit the database all the time.

Today I wanted to use a business unit dropdown on a page. So when I called it I received this error:
Code:
Error Number: 208
SELECT * FROM tblBusinessUnit ORDER BY longBU

Its strange because that query is perfectly acceptable and works on other pages. But it seems like when there are other libraries on the page it fails. I can't profile the page because it never finishes. But if I remove the businessunit_dropdown method and profile, no queries are being run, everything is cached.

I think there might be some sort of conflicts happening.
#2

[eluser]wabu[/eluser]
I just checked and it looks like that's a SQL Server error message and not a CI one (do you notice the same?).

If so and if it was me, I'd run Profiler or otherwise log the queries on the MSSQL side to make sure everything's working there. Basically, what's SQL complaining about?
#3

[eluser]whobutsb[/eluser]
See I don't think its a MSSQL problem. Because If I enter the query in exactly how it is in the MSSQL Server Management tool, I get my results no problem. I can't run the profiler. Because when the query fails, it stops executing the page and doesn't display the profiler read out.
#4

[eluser]wabu[/eluser]
Sorry, I should have specified _SQL Server_ Profiler (or otherwise log things on that end) so you could trace the query actually hitting the database and what form it's taking (is the connection right, the specified database, etc.).

If it is a SQL Server error message (and if not, whose message is it?), something about your query is making SQL cranky and this would be the way to see what form the whole statement is arriving in.
#5

[eluser]whobutsb[/eluser]
Thank you for the help. Do you know how I would configure SQL Server Logs to record the SQL Queries?
#6

[eluser]wabu[/eluser]
It's been a couple of years. Wink

No Profiler? [http://msdn.microsoft.com/en-us/library/ms187929.aspx] That's the easiest and I believe the preferred way to do it. But you do need to have the utility installed and that may not be an option depending on your situation.

If you don't have that option I think it might get more complicated due to MS's proprietary logging (IIRC there were expensive tools to analyze the log files). You might need to Google that.

Maybe this has nothing to do with your problem and is all for naught--I just wonder why you're getting that error message (which I believe is some sort of "invalid object" error on the MSSQL side).
#7

[eluser]whobutsb[/eluser]
Thanks Wabu for the help! I just ran the SQL Server Profiler tool and my query came up:

It ran the query: SELECT * FROM tblBusinessUnit ORDER BY longBU

And then came back with the error: SELECT @@ERROR AS error_number

But no other information is provided. What is weird is, if I login with the same user credentials as my app and run the query it works fine. Also I use this method else where on my application with no errors.
#8

[eluser]wabu[/eluser]
Weird.

Your original post mentioned "queries a MSSQL Database that is not the default."

Does that mean you're working with more than one database? If so, when you get the 208 error, and assuming this is an "invalid object" error, is the correct database being queried? Could it be hitting the wrong one and that's why it doesn't know what you're referring to? [And IIRC when you're tracing your app's queries in the Profiler you can see which user is hitting which database with the Transact-SQL statements.
#9

[eluser]whobutsb[/eluser]
What I meant about not default is I load the database in my model to query it. Instead of using $this->db->method(), I set it in the constructor: $this->NHCGlobal = $this->load->database('NHCGlobal', TRUE);

Do you know what the Database Errors mean? I have been looking for a reference so I can try and trouble shoot.
#10

[eluser]wabu[/eluser]
Now I had to go and fire up my crusty old XP laptop!

SQL Server Books Online has an "Errors and Events Reference" with a "Database Engine Events and Errors" subsection listing all the errors. You might be able to find it on MSDN online.

But if you just search for the 208 error itself it's out there.




Theme © iAndrew 2016 - Forum software by © MyBB