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

Upload excel data into SQL DB using CFQUERY

Community Beginner ,
Oct 04, 2010 Oct 04, 2010

Copy link to clipboard

Copied

I am using Excel 2007 and SQL 2005, but the folliwng code is not working and I am getting the message which I have set. Could you please help me out what changes to be made for my <cfquery>Tag?


Cftry> 
<CfQuery name= "MyXLQry" datasource="myXL">
Select * from [FirstTab$]
IN '#thisDirectory#\#newName#' 'EXCEL 5.0;'
</cfquery>
<cfcatch type="Database">
    <cfset message="This is not the correct Excel file as the FirstTab is not present.">
    <cflocation url="dsp_message.cfm?message=#message#" addtoken="No">
</cfcatch>
</cftry>


I have set up "myXL" as ODBC Socket in CF Admin and using CF 7.0 (don't want to CFCs)

Thanks

TOPICS
Advanced techniques

Views

1.8K

Translate

Translate

Report

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
Guest
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

You can try this way...convert it to array and then import to  db. Refer http://www.cflib.org/udf/CSVtoArray

Votes

Translate

Translate

Report

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
LEGEND ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Take the try/catch off and tell us the actual error...

To fix something, first one needs to know what the problem is.

--

Adam

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Took out all the <cftry> and <cfcatch>.

Getting HTTP 500 Internal Server rerror

Most likely causes:

  • The website is under maintenance.
  • The website has a programming error.


But the code works well with .XLS and getting error for .xlsx


is there any problem with OBDC socket or dsn?

Thanks

Votes

Translate

Translate

Report

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
LEGEND ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Dunno mate, sorry.

Are your ODBC drivers all up to date?  Like I mean the Windows ones, not the CF ones.

Have you looked @ using POI instead of ODBC?

--

Adam

Votes

Translate

Translate

Report

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
Valorous Hero ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Are your ODBC drivers all up to date?  Like I mean the

Windows ones, not the CF ones.

I am pretty sure you would need to update your drivers.  IIRC the old Jet 4 drivers do not support Office 2007 format.

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

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
Valorous Hero ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

P.S. that 500 error could be another layer of obscufication masking the real errors, IF you have not turned on the Enable Robust Exception Information option in the ColdFusion administrator of ColdFusion.

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

ODBC drivers all up to date and where can I find *Enable Robust Exception Information*?

I don't see it under Debugging &logging Settings

Thanks

Votes

Translate

Translate

Report

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
Valorous Hero ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Debugging & Logging > Debug Output Settings

Votes

Translate

Translate

Report

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
New Here ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

you'll also want to turn off friendly error messages in your browser (instructions vary depending on which one you're using)

Votes

Translate

Translate

Report

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
New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

I have the same issue as you......


Votes

Translate

Translate

Report

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
Valorous Hero ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

Did you update your drivers?

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

LATEST

It worked with the following.

 

1) Used 'EXCEL 12.0' in my query

2) Updated the drives for Excel 2007

Thanks

Votes

Translate

Translate

Report

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
Documentation