Skip to main content
Known Participant
August 19, 2019
Answered

[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name

  • August 19, 2019
  • 3 replies
  • 5708 views

This is the query that I am trying to run and I am getting the above error

<CFPARAM NAME="Form.UserLogin" default=" " TYPE="string">

<CFPARAM NAME="Form.UserPassword" default=" " TYPE="string">

<CFQUERY NAME="GetUser" DATASOURCE="Blinkey">

SELECT *

FROM OWContacts

WHERE UserLogin  = '#Form.UserLogin#'

AND UserPassword = '#Form.UserPassword#'

</CFQUERY>

<cfdump var="#GetUser#">

This query is for the login page of the intranet system that I am responsible for.

I've read several threads trying to figure out the problem and as of yet haven't found a good answer.  The code works in CF9, but I am trying CF2018 on my test server and I keep getting the error.  I've checked the DSN information and the data source that is being called is marked as the default database for the login. 

This topic has been closed for replies.
Correct answer Dave Watts

I did not set up a login/password for the DSN. I did not set up a login/password for SQL server.

I use my Windows authentication for SSMS. 

If I need to set up a username and password in SQL then I'll do that.


It's possible to use Windows authentication from CF to MS SQL Server, but for solving the immediate problem I recommend you configure SQL Server for mixed-mode authentication and create a user account in there for your application.

Dave Watts, Eidolon LLC

3 replies

srouse72Author
Known Participant
August 20, 2019

I realized after further study that the connection string that was in CF Admin was pointing to the master DB instead of Blinkey.  I changed that  and now I getting the error below:

  • Connection verification failed for data source: Blinkey
    java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot open database "Blinkey" requested by the login. The login failed.
    The root cause was that: java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot open database "Blinkey" requested by the login. The login failed.

I read somewhere that if you set the authentication to both Windows and SQL authentication (in SSMS) then you don't enter a username and password in CF Admin.

Charlie Arehart
Community Expert
Community Expert
August 20, 2019

Well, that error can mean a few things, and that feature has a little more to it than you say.

First, as for whether you have "both windows and sql auth" enabled, if you ARE specifying a username/password in the CF Admin DSN, but sql auth is NOT enabled, that will be a reason for login failure. So enabling sql auth may fix the problem.

As for if windows auth is enabled, then that means if you DO NOT specify a username/ps in the CF Admin, then CF will try to use the username that CF *runs as*. It's generically called "trusted authentication". 

Whichever the case, whatever user is then being used in CF to connect to the DB, that user has to be identified in SQL SERVER as having access to that DB.

Finally, if it IS using sql auth, and the user IS defined as having access to the DB, then make sure that password you have works. Try it in SSMS directly.

/Charlie (troubleshooter, carehart. org)
BKBK
Community Expert
Community Expert
August 20, 2019

Some suggestions:

1) Verify that there exists a table named OWContacts in the database that you registered in the Blinkey datasource. Is the name of the table perhaps OWContact ?  Was the database made case-sensitive?

2) Add try/catch as follows, and share the dump with the forum:

<cftry>

    <CFQUERY NAME="GetUser" DATASOURCE="Blinkey">

        SELECT *

        FROM OWContacts

        WHERE UserLogin  = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.UserLogin#">

        AND UserPassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.UserPassword#">

    </CFQUERY>

    <cfdump var="#GetUser#">

<cfcatch type="any">

    <cfdump var="#cfcatch#" >

</cfcatch>

</cftry>

Charlie Arehart
Community Expert
Community Expert
August 19, 2019

There are some things you are not saying, which may help us help you:

  • what "object" did it report was invalid? it could be the table name or the column names (or both)
  • is the sql server being called from CF2018 the exact same one called from CF9? And is it the same database? and using the same user defined in the CF Admin (of both CF9 and 2018)?

If you did change to using a new SQL Server instance, you may be assuming that things on the "new" sql server are configured the same as the "old", but they may not be.

  • for instance, it could be that user set in the CF Admin (for the DSN) is defined in the "new" server to not have the same default schema as was true for that user on the "old" server 
  • this is another reason why I'm asking what object it errors on. Or is there no named object?
  • have you tried just prefixing the table name with "dbo.", as in "dbo.OWContacts"? That's a traditional schema, which may work for such an old code base. But it may not work, fi your schema names are different (in sql server, for that database)
  • If that does work, then obviously you won't want to change all your code.  Again, the solution is to change that user in sql server to use that schema as their default for the table (or you may be able to change it for the table. I will leave others to elaborate on options)

If none of the above help, and especially if the error message doesn't identify the object, another option would be to copy this code into a new test page and run it from there. You could take out all but the cfquery, of course. And you could put in some sample values for the values that were to be passed in as variables. If you do that, do you get the same error?

  • what if you then take out the where clause? (you may want to change the "select *" to a "select count(*)", so that it doesn't return ALL rows and cols, but instead just a count of the number of rows)

Those are a few thoughts to try to get you started.

/Charlie (troubleshooter, carehart. org)
srouse72Author
Known Participant
August 19, 2019

The error was on the table name OWContacts.  No, it is a different named database on a different server.  Yes, I have tried prefixing the able name, and I pulled the code and put it in a test page.  The data source that is being called is the default database in SQL and the schema is dbo.

Charlie Arehart
Community Expert
Community Expert
August 20, 2019

Ok,  but look in sql server: what is the default schema for that user (defined in the cf admin), for that database which the dsn points to.

You can also try logging into ssms with that same user, and try the same query there. If it fails there, it confirms that the problem is not about CF. (I realize you just want it solved. I'm saying I think the answer is in sql server setup, not cf setup.,)

If it doesn't happen there, then we're back to what in CF could be causing this. But let's wait and see.

/Charlie (troubleshooter, carehart. org)