portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

Problem picking-up my datasource

| View in Portal
December 20, 2019 10:41:08 PM GMT
6 Comments
<p>Any assistance would be appreciated ?? I connected my CF2018 to my mariaDB server: Actions Data Source Name Driver Status rhce MySQL OK But, I’m getting below output: SELECT sno, firstname, lastname, city, country, age FROM scientists Sno FirstName LastName City Country Age #sno# #firstname# #lastname# #city# #country# #age# From my RHEL7 server, I can pull the data: MariaDB [rhce]> select * from scientists; +——+———–+————+————-+———+——+ | Sno | Firstname | LastName | City | Country | Age | +——+———–+————+————-+———+——+ | […]</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/12/problem-picking-datasource/">Problem picking-up my datasource</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: CF2018 Updates, ColdFusion 2018, Question, 2018, cf2018 updates, coldfusion 2018, mysql, question

Comments:

Hi, I am reasonably new to Coldfusion (less than 12 months) but I would try this... <html> <head> <title>Using cfoutput</title> </head> <body> <table border=”1?> <tr> <th>Sno</th> <th>FirstName</th> <th>LastName</th> <th>City</th> <th>Country</th> <th>Age</th> </tr> <cfoutput> <cfloop query=”getScientists”> <tr> <td>#sno#</td> <td>#firstname#</td> <td>#lastname#</td> <td>#city#</td> <td>#country#</td> <td>#age#</td> </tr> </cfloop> </cfoutput> </table> </body> </html>
Comment by Jenkar78
3584 | December 23, 2019 04:04:54 PM GMT
Marty, you don't clarify it, but is this the first CF page you are running? If so, your problem has nothing to do with your sql or datasource (despite your title). Instead, the output you show is indicating that the CFML is not running at all. Instead, if you do a "view source" on your page's output (using the browser menu or a right-click in the page content), you will see that you actually SEE your CFML underlying your page. The CFML is not running. So show us first the URL you are using to browse your page. It may be simply that you are not requesting the URL via a web server (CF's or another). Or it may be that your web server has a configuration problem so that the URL is not being passed into CF to execute the CFML.
Comment by Charlie Arehart
3582 | December 23, 2019 08:26:21 PM GMT
Marty, as Charlie mentioned that it is quite possible that CFML is not running at all. Can you please let us know where you are putting your code? <ol> <li>Webserver(IIS/Apache),</li> <li>Or In ColdFusion's webroot - \cf-root\cfusion\wwwroot\</li> </ol> If you are putting this in IIS/Apache webroot, do you have the connector for ColdFusion?
3591 | December 24, 2019 02:31:49 PM GMT
Marty-- As Charlie and Priyank said, it sounds like you need to verify that CF is actually running on your web server. To help debug that problem, I create the following test file in the root of my webserver (usually name the file 'test1.cfm'): <cfset OutputStr = "Hello Word"> <cfsetting showdebugoutput = "yes"> <html> <head> <title>ColdFusion Test</title> </head> <body> <h1>ColdFusion Test</h1> <p> <cfoutput> #OutputStr# </cfoutput> </p> </body> </html> Then use your browser to load the page (eg, <strong>http://localhost/test1.cfm</strong> or <strong>http://localhost:8500/test1.cfm</strong> or something similar depending on your configuration). If you see 'Hello World' CF is running and all is good. If you see '#OutputStr#' or other stuff, CF isn't processing your page. Once you verify that CF is running, here's another tip for you. In your code, right after the </cfquery> tag, use CFDUMP to show the results of your DB query: <cfdump var="#getScientists#" expand="yes" output="browser"> This will show you the results of the query without having to deal with cfloop or creating table elements. The cfdump tag can really be a time-saver to debug data issues, especially with complex data like query results. <a href="https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdump.html" rel="nofollow">More info here</a>. [Note: if you're using cfscript syntax, it's writeDump() instead of cfdump. ] Hope that helps, Mark    
Comment by marklgeol
3597 | December 31, 2019 05:22:49 AM GMT
<p>Mark, what you say is helpful (or I hope it will be for Marty), and in the same spirit of helpfulness I will point out for both your sakes that your code samples could be reduced considerably. The first could be done in just 2 lines as:</p><pre> <cfset OutputStr = “Hello Word”> <cfoutput>#OutputStr#</cfoutput><br /><br /></pre><p>All the HTML really is unnecessary (as is the cfsetting, since it has no impact on the code that's running).  And your offered CFDUMP could be done with just the one attribute: </p><pre> <cfdump var=”#getScientists#”><br /><br /></pre><p>since the expand and output attribute values you indicated are the defaults.</p>
Comment by Charlie Arehart
3598 | December 31, 2019 03:39:55 PM GMT
Charlie--Thanks for the comments. Always looking for shorter ways to code although I tend to explicitly code some attributes with the defaults just to make the code more self-documenting and remind myself what's happening.    
Comment by marklgeol
3599 | December 31, 2019 11:12:02 PM GMT