Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFQUERY results return a null value for a varchar(MAX) field in SQL

Explorer ,
Sep 08, 2011 Sep 08, 2011

I'm using ColdFusion 9 and SQL Server 2008.

One the fields in a table is defined as a varchar(MAX). Other fields in the table are ints, varchar(8000) varchar(256), etc.

When doing a query for records in the table and displaying the results using the cfdump tag, I see values in all fields in a row EXCEPT for the data in the varchar(MAX) field. The varchar(MAX) field shows a null value.  Yet, I can verify through the SQL interface or through Microsoft Access querying the database that the varchar(MAX) fields have data.

How can I retrieve data from this field type?

Thanks in advance for your help.

TOPICS
Database access
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 09, 2011 Sep 09, 2011
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2011 Sep 11, 2011

Sadly, that didn't fix it. I went to ColdFusion Administrator, Data Sources and clicked on Advanced Settings. For the first time, I added

checks to the CLOB and BLOB settings, saved the settings and double checked that checkmarks remained. Even after rebooting the

server, however, when I use the <CFQUERY> tag to return records for the table with the varchar(MAX) in it, all fields except the

varchar(MAX) contain data. The value for the varchar(MAX) is still [empty string].

This datasource uses an ODBC driver. Could that cause the problem? I use the same ODBC driver to retrieve data from the table into

Microsoft Access. Access queries retrieve the information correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 12, 2011 Sep 12, 2011

Have you tried using the JDBC driver bundled with ColdFusion? Use of JDBC is generally recommended over ODBC.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 15, 2011 Sep 15, 2011

I'm not sure what you mean by using the JDBC driver.

In the past, to create a datasource used by ColdFusion, I've followed two steps.

     1. Go to Control Panel/Administrative Tools/Data Bases (ODBC). Click on the System DSN tab. Create a datasource there using the SQL Server driver.

     2. Browse to the ColdFusion Administrator/Data Sources/Add Datasource. Choose the ODBC socket as the driver type when creating the datasource.

The process is incorrect, right? So,

     a. Do I even create a datasource on the local machine outside of CF Administrator as described in item 1 above? I only see ODBC as a datasource entry point there.

     b. Within ColdFusion Administrator's drop down menu of driver types, I don't see anything named JDBC.

This may seem obvious to most people. I apologize for my lack of understanding.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 15, 2011 Sep 15, 2011

The drivers bundled with CF are JDBC drivers.  Using these is generally preferable to the ODBC socktet driver.  The CF documentation states, about using ODBC: "Adobe does not recommend this driver type unless your application requires DBMS-specific features."

Instructions for creating a database connection (JDBC) to SQL Server can be found in the CF documentation.  Your step 1 is not required when using JDBC.

References:

"About JDBC"
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf3639b1-7ffd.html


"Connecting to Microsoft SQL Server"
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fe5.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 15, 2011 Sep 15, 2011

Your message was very helpful. The driver change fixed the query results problem. Do you want me to try to explain this in the forum message? I'm not sure it would be useful for anyone to read as it is. Or, should I delete the thread?

Thank you so very much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 15, 2011 Sep 15, 2011
LATEST

I would describe the steps that fixed your problem here in the forum in so it can help someone else with a similar problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2011 Sep 11, 2011

I'm wrong. I AM getting query results, but not what I expect. I had maxrows set as a variable in my original query, so when it returned 5 rows, the first row always showed as [empty string]. I've tried numerous queries now (where UID >100, where UID >200, where UID> 300, etc.) When I use <CFDUMP> to return the query, the first records always shows empty strings.

Here's an example of some records retrieved from this simple query:

<CFQUERY NAME="BuildBack" DATASOURCE="STORBASE">
SELECT *

FROM CallUnit

WHERE CCU_ID>172

</CFQUERY>

Any ideas?

173Ptuse322340
174E323340
175Ptuses.324341
176E325341
177Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupC326342
178Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCa327343
179E328344
180E329345
181Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCall_330346
182P331347
183E332348
184P333349
185Ptuses.SCStat_ID)334350
186Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCall_Prior335352
187E336353
188P337354
189Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCall_Priorities.SCPriority_ID) LEFT JOIN SupCall_CommTypes ON SupCall_MetaData.CommunicationType = SupCall_CommTypes.SCComm_ID) INNER JOIN SupCall_CallStages ON SupCall_338355
190Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCall_Priorities.SCPriority_ID) LEFT JOIN SupCall_CommTypes ON SupCall_MetaData.CommunicationType = SupCall_CommTypes.SCComm_ID) INNER JOIN SupCall_CallStages ON SupCall_M339356
191Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_340357
192Ptuses.SCStat_ID) á àh\  (9~ Hbb l_Products ON SupCall_MetaData.Product = SupCall_Products.SCPL_ID) LEFT JOIN SupCall_Priorities ON SupCall_MetaData.Priority = SupCall_Priorities.SCPriority_ID) LEFT JOIN SupCall_CommTypes ON SupCall_MetaData.CommunicationType = SupCall_CommTypes.SCComm_ID) INNER JOIN SupCall_CallSta341358
193Ptuses.SCStat_ID) á àh\

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources