我想...
- 打开数据库连接
- 将html表单数据放入Access 2007数据库
- 使用FDF Toolkit
将相同的表单数据传递到已创建的PDF表单中- 将该PDF表格保存到网络驱动器
- 向用户显示消息,或者最好显示刚刚创建的PDF。
醇>
我正在将表单数据传递给数据库就好了,我遇到麻烦......
objFDf.FDFSaveToFile“:\ Project_Setup_Records \ Test \”& “<%= rs1(”PID“)”& “.fdf”
它似乎不喜欢路径中的变量,尽管我可能会咆哮错误的树。当我运行页面时,我收到以下消息....
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/forms/RequestConfirmation.asp, line 141
objFDf.FDFSaveToFile "<Drive>:\Project_Setup_Records\Test\" & "<%=rs1("PID")" & ".fdf"
-----------------------------------------------------------------^
任何人都可以分析这段代码并提出一种方法,我可以让这个FDF保存(我需要为每个FDF设置一个唯一的FDF名称)吗?谢谢!
我的代码低于.....
<%@ LANGUAGE = VBScript%>
<%
'Dimension variables
Dim objConn 'Holds the Database Connection Object
Dim rs1 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set objConn = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using DSN connection
objConn.Open "DSN=XDRIVE"
'Create an ADO recordset object
Set rs1 = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM Data_Info;"
'Set the cursor type we are using so we can navigate through the recordset
rs1.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rs1.LockType = 3
'Open the recordset with the SQL query
rs1.Open strSQL, objConn
'Tell the recordset we are adding a new record to it
rs1.AddNew
'Add a new record to the recordset
rs1.Fields("PID") = Request.Form("PID")
rs1.Fields("EA") = Request.Form("EA")
rs1.Fields("Rte_Desc") = Request.Form("Rte_Desc")
rs1.Fields("PM_FN") = Request.Form("PM_FN")
rs1.Fields("PM_LN") = Request.Form("PM_LN")
rs1.Fields("PM_S_Num") = Request.Form("PM_S_Num")
rs1.Fields("PM_Phone") = Request.Form("PM_Phone")
rs1.Fields("PE_FN") = Request.Form("PE_FN")
rs1.Fields("PE_LN") = Request.Form("PE_LN")
rs1.Fields("PE_S_Num") = Request.Form("PE_S_Num")
rs1.Fields("PE_Phone") = Request.Form("PE_Phone")
rs1.Fields("FileMgr_FN") = Request.Form("FileMgr_FN")
rs1.Fields("FileMgr_LN") = Request.Form("FileMgr_LN")
rs1.Fields("FileMgr_S_Num") = Request.Form("FileMgr_S_Num")
rs1.Fields("FileMgr_Phone") = Request.Form("FileMgr_Phone")
rs1.Fields("Des_Ste_FN") = Request.Form("Des_Ste_FN")
rs1.Fields("Des_Ste_LN") = Request.Form("Des_Ste_LN")
rs1.Fields("Des_Ste_S_Num") = Request.Form("Des_Ste_S_Num")
rs1.Fields("Des_Ste_Phone") = Request.Form("Des_Ste_Phone")
rs1.Fields("Ass_Ste_FN") = Request.Form("Ass_Ste_FN")
rs1.Fields("Ass_Ste_LN") = Request.Form("Ass_Ste_LN")
rs1.Fields("Ass_Ste_S_Num") = Request.Form("Ass_Ste_S_Num")
rs1.Fields("Ass_Ste_Phone") = Request.Form("Ass_Ste_Phone")
'Write the updated recordset to the database
rs1.Update
'*** Create the FDF object.
Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")
Dim objFdf
Set objFdf = FdfAcX.FDFCreate
'*** Set the location of the PDF file you create.
objFdf.FDFSetFile "http://xxxxxxxxxx/xxxxxx/Design/design/forms/Project Folder Information_Form.pdf"
'*** Set the variables with data from the various Request
'*** data name/ value pairs posted from the HTML form. I'm using
'*** rather verbose code here, hopefully to benefit beginners
PID = Request.form("PID")
EA = Request.form("EA")
Rte_Desc = Request.form("Rte_Desc")
PM_FN = Request.form("PM_FN")
PM_LN = Request.form("PM_LN")
PM_S_Num = Request.form("PM_S_Num")
PM_Phone = Request.form("PM_Phone")
PE_FN = Request.form("PE_FN")
PE_LN = Request.form("PE_LN")
PE_S_Num = Request.form("PE_S_Num")
PE_Phone = Request.form("PE_Phone")
FileMgr_FN = Request.form("FileMgr_FN")
FileMgr_LN = Request.form("FileMgr_LN")
FileMgr_S_Num = Request.form("FileMgr_S_Num")
FileMgr_Phone = Request.form("FileMgr_Phone")
Des_Ste_FN = Request.form("Des_Ste_FN")
Des_Ste_LN = Request.form("Des_Ste_LN")
Des_Ste_S_Num = Request.form("Des_Ste_S_Num")
Des_Ste_Phone = Request.form("Des_Ste_Phone")
Ass_Ste_FN = Request.form("Ass_Ste_FN")
Ass_Ste_LN = Request.form("Ass_Ste_LN")
Ass_Ste_S_Num = Request.form("Ass_Ste_S_Num")
Ass_Ste_Phone = Request.form("Ass_Ste_Phone")
'
' Stuff the variables
'
objFdf.fdfsetvalue "PID", PID, false
objFdf.fdfsetvalue "EA", EA, false
objFdf.fdfsetvalue "Rte_Desc", Rte_Desc, false
objFdf.fdfsetvalue "PM_FN", PM_FN, false
objFdf.fdfsetvalue "PM_LN", PM_LN, false
objFdf.fdfsetvalue "PM_S_Num", PM_S_Num, false
objFdf.fdfsetvalue "PM_Phone", PM_Phone, false
objFdf.fdfsetvalue "PE_FN", PE_FN, false
objFdf.fdfsetvalue "PE_LN", PE_LN, false
objFdf.fdfsetvalue "PE_S_Num", PE_S_Num, false
objFdf.fdfsetvalue "PE_Phone", PE_Phone, false
objFdf.fdfsetvalue "FileMgr_FN", FileMgr_FN, false
objFdf.fdfsetvalue "FileMgr_LN", FileMgr_LN, false
objFdf.fdfsetvalue "FileMgr_S_Num", FileMgr_S_Num, false
objFdf.fdfsetvalue "FileMgr_Phone", FileMgr_Phone, false
objFdf.fdfsetvalue "Des_Ste_FN", Des_Ste_FN, false
objFdf.fdfsetvalue "Des_Ste_LN", Des_Ste_LN, false
objFdf.fdfsetvalue "Des_Ste_S_Num", Des_Ste_S_Num, false
objFdf.fdfsetvalue "Des_Ste_Phone", Des_Ste_Phone, false
objFdf.fdfsetvalue "Ass_Ste_FN", Ass_Ste_FN, false
objFdf.fdfsetvalue "Ass_Ste_LN", Ass_Ste_LN, false
objFdf.fdfsetvalue "Ass_Ste_S_Num", Ass_Ste_S_Num, false
objFdf.fdfsetvalue "Ass_Ste_Phone", Ass_Ste_Phone, false
objFDF.fdfSetFile "<Drive>:\Project_Setup_Records\Project Folder Information_Form.pdf"
Response.ContentType = "text/html"
'
' Save it to a file. If you were going to save the actual file past the point of printing
' You would want to create a naming convention (perhaps using social in the name)
' Have to use the physical path so you may need to incorporate Server.mapPath in
' on this portion.
'
'*** Use the FDFSetStatus method to display an alert status box.
objFdf.FDFSetStatus "Your PDf File has been created and sent for review. You will be notified when your folder has been created."
objFDf.FDFSaveToFile "<Drive>:\Project_Setup_Records\Test\" & "<%=rs1("PID")" & ".fdf"
' Now put a link to the file on your page.
Response.Write "<a href=<%path%>X-Drive Request Form</a>"
'*** Write the data back to the buffer stream.
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite objFdf.FDFSaveToBuf
'*** Close the object and clean-up.
objFdf.FDFClose
Set objFdf = Nothing
Set FdfAcX = Nothing
Response.end
'Redirect to the confirmation.asp page
'Response.Redirect "CreatePDF.asp"
'Reset server objects
rs1.Close
Set rs1 = Nothing
Set objConn = Nothing
%>
答案 0 :(得分:4)
我没有使用ASP的经验,但你可能应该改变这个:
"P:\Project_Setup_Records\Test\" & "<%=rs1("PID")" & ".fdf"
进入这个:
"P:\Project_Setup_Records\Test\" & rs1("PID") & ".fdf"
如果要生成以PID作为文件名的路径。