我最近繼承了一個連接到sql server數據庫的舊的visual basic 6/crystal reports項目。當我嘗試運行該項目我得到(錯誤#-2147191803一個字符串這裏需要)的錯誤信息,似乎在下面的代碼將被縮小到.Printout命令:VB6/Crystal Report 8.5錯誤:這裏需要一個字符串
'Login to database Set Tables = Report.Database.Tables Set Table = Tables.Item(1) Table.SetLogOnInfo ConnName, DBName, user, pass DomainName = CStr(selected) 'Set parameter Fields 'Declare parameter holders Set ParamDefs = Report.ParameterFields 'Store parameter objects For Each ParamDef In ParamDefs With ParamDef MsgBox("DomainName : " + DomainName) Select Case .ParameterFieldName Case "Company Name" .SetCurrentValue DomainName End Select Select Case .Name Case "{?Company Name}" .SetCurrentValue DomainName End Select 'Flag to see what is assigned to Current value MsgBox("paramdef: " + ParamDef.Value) End With Next Report.EnableParameterPrompting = False Screen.MousePointer = vbHourglass 'CRViewer1.ReportSource = Report 'CRViewer1.ViewReport test = 1 **Report.PrintOut** test = test + 3 currenttime = Str(Now) currenttime = Replace(currenttime, "/", "-") currenttime = Replace(currenttime, ":", "-") DomainName = Replace(DomainName, ".", "") startName = mPath + "\crysta~1.pdf" endName = mPath + "\" + DomainName + "\" + DomainName + " " + currenttime + ".pdf" rc = MsgBox("Wait for PDF job to finish", vbInformation, "H/W Report") Name startName As endName Screen.MousePointer = vbDefault End If
在運行過程中,表單顯示出來,ParamDef變量設置「公司名稱」,當它到達提示打印的行時,它會拋出錯誤。我猜水晶報告沒有收到「公司名稱」來正確運行水晶報告。是否有人知道如何診斷這個......無論是在vb6還是水晶報告方面,以確定我在這裏失蹤的東西?
UPDATE:
- 插入的CStr的(所選擇的)來強制域名是一個字串
- 插入msgboxes到for循環的上方和.setcurrentvalue線以下
- 插入案「{?公司名稱}「聲明,看看是否有助於設置值
- 嘗試.AddCurrentValue和.SetCurrentValue函數建議由其他論壇網站
- 排除了這是我的開發environement ..加載它在另一臺機器上完全相同的vb6水晶報告8.5運行在winxp prof sp2上並出現相同的錯誤。
,當我運行MSGBOX(ParamDef.Value),也變成了空白含有相同缺少字符串錯誤。我也找不到有關craxdrt.ParameterFieldDefinition類的任何文檔,以查看可用的其他隱藏函數。當我看到方法和屬性變量列表時,它沒有列出SetCurrentValue作爲其中一個函數。 有關於此的任何想法?
謝謝,但這並沒有真正的幫助。它設置參數的方式似乎完全不同於.NET – phill 2008-09-23 16:32:34