Solved

Coldfusion SQL Server 2005 connectivity issue

Posted on 2006-11-12
16
244 Views
Last Modified: 2013-12-24
Experts,

I'm having troubles getting SQL Server 2005 Express to recognize my CF queries. I had SQL Server and CF working properly but had hard drive issues and had to reformat. I've reinstalled everything but now I'm getting this error message on all queries:

 Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'color'.
 
The error occurred in C:\Inetpub\wwwroot\cfdocs\ruthSisters\store\test.cfm: line 11

9 :
10 : <!--- <cfquery name="getCategories" datasource="#request.db#" username="#request.username#" password="#request.password#"> --->
11 : <cfquery name="getCategories" datasource="ruthsisters" username="sa" password="xxxxxxx">
12 :       SELECT      *
13 :       FROM      color
14 : </cfquery>

"Color" is the name of a column in the database.

The install for both CF and SQL I believe is fine. I'm concerned because usually I've assigned port 1433 to the SQL db in the CF admininistrator. The only way CF will verify the db is if I use port 1259. I've went into Windows administrative tools and established an ODBC connect which is verified. I believe that I have everything as before but something is not working.

Thank you for any help you can give!!!!!

rr
0
Comment
Question by:rruth
16 Comments
 
LVL 7

Expert Comment

by:aseusainc
ID: 17927616
The FROM field should be referencing a table name within the database, not a column name.

Try

SELECT color
FROM tablename
0
 

Author Comment

by:rruth
ID: 17927742
I'm sorry color is a table in the database not a column.

rr
0
 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 17931414
It sounds to me like you need to change SQL Server's configuration to use port 1433 instead of 1259.

M@
0
 

Author Comment

by:rruth
ID: 17934305
ExpertAdmin,

I went into the SQL Server Configuration Manager, clicked on Protocols for SQLEXPRESS, right clicked on TCP/IP and clicked on Properties and changed the port  from 1259 to 1433. I then went back into CF Admin/datasource and changed the port there to 1433. I get the same error message: Invalid object name.

I don't know what else to do. I really appreciate your help!!!

rr
0
 
LVL 4

Expert Comment

by:boy8964
ID: 17935124
Why don't you try to use cf administrator to set up a DNS for you. When you finshied setting DNS you can verify the connection. Make use it is working!
0
 

Author Comment

by:rruth
ID: 17935218
boy8964,

Again, originally I had SQL 2005 and CF working. After I reformatted by hard drive and re-installed everything, all my queries in the app I was working on through an error saying that the name of my table is invalid.

I've went into the CF Admin and verified the connection to my table. I've went into SQL Server Configuration Manager and changed the port from 1259 to 1433. I've also went into Windows Admin tools and verified the ODBC connection there.

I'm really desparate. I now have reformatted by hard drive twice hoping that I had done something wrong the first time!!!!!!!!!!

I really, no I mean I REALLY appreciate any help you can give!

rr
0
 
LVL 7

Accepted Solution

by:
ExpertAdmin earned 500 total points
ID: 17937826
OK...if you are getting an error stating that the name of your table is invalid then you are getting through to SQL Server. That is a SQL error, not a connection error.

It sounds to me like you now have the wrong default database selected in your connection. It defaults to "Master" which would prevent your queries from seeing your tables. There is an easy way to test this:

Modify one of your queries to fully qualify the table name. For example, if you have a table named Customer in a database named Sales, use this syntax on a select statement:

SELECT * FROM Sales..Customer

instead of

SELECT * FROM Custome

If this works then you have the wrong default database selected in your connection. An easy fix. If this does not work, please copy the error and paste it in a reply so we can see exactly what it is complaining about.

Thanks,

M@
0
 

Author Comment

by:rruth
ID: 17939324
ExpertAdmin,

You are going the right direction with this. What I did is create a query that used the DNS for my database (ruthsisters) but actually used a table (spt_values) that is in the master database and it worked, returning every value in a column called "Name". Here is a look at the query:

<cfquery name="getMaster" datasource="ruthsisters" username="sa" password="xxxxxx">
      SELECT *
      FROM      spt_values
</cfquery>

<cfoutput query="getMaster">
      #Name#<br />
</cfoutput>

How can I get SQL to find my database?

Again, THANK YOU for you help!

rr
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 17939397
Go back to your DSN and set the Default Database property to your database. There should be a setting that will allow you to choose it from a dropdown list.

M@
0
 

Author Comment

by:rruth
ID: 17948203
ExpertAdmin,

I found that if I add the option: dbname="ruthsisters" to my query it finds the correct database. I uploaded the test query to my ISP with the "dbname" option and it functions normally there. I'm not sure why after re-installing SQL Server that I now have to include the "dbname" option. This means that I will do a search and replace on all queries to add this option so they work properly on my local development computer. I can live with this. If you have any insight on why the change I would really appreciate knowing.

<cfquery name="getAdmin" datasource="ruthsisters" username="sa" password="xxxxxxx" dbname="ruthsisters">
      SELECT *
      FROM      admin
</cfquery>

It was your clue that SQL Server was defaulting to the master db that helped me work this out. I really appreciate your help and if you know why this happened I would love to know also!

rr
0
 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 17948743
Again, I don't think that SQL Server is the real problem. Were you able to set the default DB in your ODBC connection?

M@
0
 

Author Comment

by:rruth
ID: 17951579
ExpertAdmin,

No I was not able to locate the place to make that selection. I'm finding that I'm still having some problems. After adding the "dbname" attribute to the example query above, the query functioned as expected. But even with the dbname attribute added some of my queries are still throwing the same error message. This is really frustrating because these are all queries that functioned properly before the melt down of my hard drive. Do you have any suggestions where I can make this selection?

Again, thanks for your help!

rr
0
 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 17952909
I am assuming that your DSN is set up in Windows. If that is the case, you can go to Control Panel, ODBC Connections, then click on the Machine Data Sources tab. You should see a list of DSNs, and yours should be in that list. If you double click on the name, you should get a dialog that lets you set the username, password, and default database.

Here are the step by step instructions:

http://www.depts.ttu.edu/helpcentral/directions/ODBCSetup.php

M@
0
 

Author Comment

by:rruth
ID: 17953252
ExpertAdmin,

I went into the Windows Admin Tools and found the default db option you mentioned. While there I noticed that I had mistakenly setup my database under the System DSN tab instead of the User DSN. I removed it and than re-added it under User. Pretty lame! I never changed my default settings and all my queries are now working. Thank you again for sending me in the right direction and going the extra mile!!!

rr
0
 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 17955266
That is great news. You are welcome.

One thing...you should be able to use either a system or a user DSN the same with no problems. The main difference is that a user DSN will only be visible when you are logged in. If you are setting up a server DSN you will need to make sure it is a System, not User DSN because otherwise it will not be available when you are not logged in.

M@
0
 

Author Comment

by:rruth
ID: 17957456
ExpertAdmin,

That makes sense. Thank you for all your help!

rr
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now