Skip to main content
Inspiring
November 29, 2012
Answered

Uploading and querying an mdb file

  • November 29, 2012
  • 3 replies
  • 3585 views

Hi , I was wondering if it was possible uploading an mdb file and parsing it to output a pdf file through cf...

I know I have therefor need to have a dsn-less connection to that file to start with.
I tried :

<cfif isdefined("form.fileData")>

      <cfscript> 

            hello = FileUpload("C:\inetpub\wwwroot\cvt\","form.fileData","application/msaccess","MakeUnique");

      </cfscript>

      <cfdump var="#hello#">

<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)};Dbq=#hello.serverfile#;Uid=Admin;Pwd=somepwd;");

st = con.createStatement();

rs = st.ExecuteQuery("Select * FROM tblbarcode");

q = createObject("java", "coldfusion.sql.QueryTable").init(rs);

//the query is stored in the variable q

</cfscript>

      <cfquery name="GetExample" datasource="q" dbtype="query">

Select        *

From          tblbarcode

</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>

and i get :

No suitable driver found for Driver={Microsoft Access Driver (*.mdb)};Dbq=stockwagen15.mdb;Uid=Admin;Pwd=somepwd;

If i change jdbc:odbc:DRIVER to Driver , I get

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


I also tried using a complete path to the file, same error ...

This topic has been closed for replies.
Correct answer Benutti

Found out after a heck of a search ... comes out that access driver is otherwise spelled ...

{Microsoft Access Driver (*.mdb)} needs to be
{Microsoft Access Driver (*.mdb, *.accdb)}

And you need to mind the SPACE after the comma, otherwise it's a no-go ...

3 replies

BenuttiAuthorCorrect answer
Inspiring
December 2, 2012

Found out after a heck of a search ... comes out that access driver is otherwise spelled ...

{Microsoft Access Driver (*.mdb)} needs to be
{Microsoft Access Driver (*.mdb, *.accdb)}

And you need to mind the SPACE after the comma, otherwise it's a no-go ...

BKBK
Adobe Expert
November 29, 2012

You might be interested in this previous thread on using ACCDB files in ColdFusion.

BenuttiAuthor
Inspiring
November 29, 2012

Can't, that describes how to connect to a accdb file , using a datasource.

what i need is to be able to connect to a MDB file that is random by name . which you can't define as a datasource.

Inspiring
November 29, 2012

If your plan is to continually upload new mdb files you need a better plan.  Consider:

Using db software designed for client server on your server.  There are choices, some free, some not so free.

Designing your database and writing a front end for writing data.

Import your data from access.

Upload the new db to the server and use it in your coldfusion apps.

Even if you want to continue to use access, you want to write data to the db that's on your server.

BenuttiAuthor
Inspiring
November 29, 2012

The main purpose of this script is to make a printable version of an mdb file that is used on multiple field terminals, representing the stock of materials of that technician

Inspiring
November 30, 2012

If every person has their own access file, could you not generate a report inside access that makes a printable version and then distribute it?