3

What I am trying to achieve.

I am uploading a .mdb file. After uploading I want to read the data from the uploaded file.

What I have done so far.

After referring this(Uploading and querying an mdb file), I have written this code.

<cfif isdefined("form.fileData")>
    <cffile action = "upload" destination = "D:\Experiments" fileField = "form.fileData" nameConflict = "MakeUnique" result ="hello" strict="false">   
    <cfdump var="#hello#">   
    <!--- The file upload is working fine --->
    <cfscript>  
        classLoader = createObject("java", "java.lang.Class");  
        classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");  
        dm = createObject("java","java.sql.DriverManager");  

        con = dm.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=#hello.serverfile#;");  

        st = con.createStatement();  
        rs = st.ExecuteQuery("Select * FROM Classes");  
        q = createObject("java", "coldfusion.sql.QueryTable").init(rs);  
    //the query is stored in the variable q   
    </cfscript>  
    <cfquery name="GetExample" dbtype="query">  
        SELECT        *  
        FROM          q  
    </cfquery>  
    <cfdump var="#GetExample#">  

<cfelse>   
    <cfform name="myUpload" enctype="multipart/form-data">   
        <cfinput type="file" name="fileData"><br>   
        <cfinput type="submit" name="submit" value="Verzenden">   
    </cfform>   
</cfif>

But I am getting an error

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

After referring this answer I have tried by giving absolute path. But it is also giving same error.

Error!!

enter image description here

Community
  • 1
  • 1
Rino Raj
  • 6,264
  • 2
  • 27
  • 42
  • If you have dbtype = "query", you can't have a datasource. That might not be your immediate problem, but it eventually will be. – Dan Bracuk Apr 13 '16 at 12:13
  • Yes, I will remove that. This was copied from somewhere. – Rino Raj Apr 13 '16 at 12:16
  • I have updated the question. – Rino Raj Apr 13 '16 at 12:21
  • I have not used Access in a long while but .. a couple thoughts. A) Which o/s and version of CF - 32 or 64bit? Sounds like it [*might* be a bitness issue](https://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/). B) Do you have any *existing* Access DSN's set up on the server? IIRC, older versions of Access supported a special syntax ie, `FROM Table IN "c:\path\db.mdb` that allowed you to use an existing DSN as a sort of pass-through mechanism to access another db file. No idea if that is still supported. – Leigh Apr 13 '16 at 15:30
  • @Leigh Both OS and Cf are 64 bit. I don't have any existing Access DSN. I'll try with the suggestion you told. – Rino Raj Apr 15 '16 at 04:54
  • @RinoRaj - Also, not sure if it still applies, but [this thread](http://blogs.coldfusion.com/post.cfm/coldfusion-10-64bit-and-msaccess) about CF10 64 bit, mentioned Access odbc dsn's are not supported, but provided a work around. Hopefully either this link or the previous one will work. – Leigh Apr 18 '16 at 14:49

0 Answers0