我想要实现的目标。
我正在上传.mdb
个文件。上传后我想从上传的文件中读取数据。
到目前为止我做了什么。
在提到this(Uploading and querying an mdb file)后,我写了这段代码。
<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>
但我收到错误
[Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序
在提到this answer后,我试过给出绝对路径。但它也给出了同样的错误。
错误!!