xtrpt 為Report對象
在8.5下 xtRpt.Database.AddADOCommand mCnn, mCmd 正常
在9.0下 xtRpt.Database.AddADOCommand mCnn, mCmd 出錯
錯誤信息:creation feature not enabled.
報表運行環境:9.0 + vb
在8.5下 xtRpt.Database.AddADOCommand mCnn, mCmd 正常
在9.0下 xtRpt.Database.AddADOCommand mCnn, mCmd 出錯
錯誤信息:creation feature not enabled.
報表運行環境:9.0 + vb
解决方案 »
- VB画面中的按钮控件在运行时总是一闪一闪的,大家有没有碰到过这种问题,有什么解决的办法吗??
- mdb数据库,利用cn执行完任务后,档案是否还被锁定,如何解除锁定那?请大家帮帮忙。谢谢。
- 已经转JAVA的。或要转的。报名吧。。
- http://www.66p.cn/gg.htm怎么与众不同?哪位达人帮我看看这个页面,怎么才能在上面的文字上分别用VB代码点击一下?
- 有没有方法能够把我编写的VB程序自动的转换成网页.另外网页与程序之间传送数据有没有好的方法.
- 请问如何使文本框透明显示?
- vb6如何连接oracle10,在线等
- 帮忙看一下。谢谢!
- 高分急救!字符串转换问题?
- 我马上没有分数了,我该怎么办?
- unicode疑问
- 欢迎大家到我的破站做客~没时间维护想请高手维护http://infofox.org
' Purpose: Demonstrate new methods of adding ADO connections to reports
' (New to Crystal Reports 8.0)
'
' There are two new methods that provide a convenient
' way to add ADO data sources to a report:
' 1.) AddADOCommand takes as parameters an active ADO connection
' and an ADO command object. In this example, a new connection
' is created to a database, and the resulting recordset is assigned
' at runtime to the report
' 2.) AddOLEDBSource takes as parameters the name of an active
' ADO connection and the name of a table that can be accessed
' through that connection. In this example, the connection set
' up through the VB Data Environment is used as a data source.
'
' Both methods can be used with either the VB Data Environment
' or another data source created at runtime.
' Notice in the Crystal Report design environment that there is
' no data source attached to the report at design time.
'
Option ExplicitDim m_Report As New CrystalReport1' The ADO connection to the local database.
Dim cnn1 As ADODB.Connection
Dim datcmd1 As ADODB.Command' *************************************************************
' Demonstrate the use of AddADOCommand by opening an ADO data command,
' adding the data source to the report, and then adding a field
' to the report that uses that data source.
'
Private Sub cmdADO_Click()
Dim fld As FieldObject
Dim strCnn As String
' Open the data connection
Set cnn1 = New ADODB.Connection
strCnn = "Provider=MSDASQL;Persist Security Info=False;Data Source=Xtreme Sample Database 9;Mode=Read"
cnn1.Open strCnn ' Create a new instance of an ADO command object
Set datcmd1 = New ADODB.Command
Set datcmd1.ActiveConnection = cnn1
datcmd1.CommandText = "answers"
datcmd1.CommandType = adCmdTable ' Add the datasource to the report
m_Report.Database.AddADOCommand cnn1, datcmd1
' Add a new field object to the report and set the field object to use
' the new data source.
Set fld = m_Report.Section3.AddFieldObject("{ado.answers answer}", 0, 0)
LoadReport
End Sub' *************************************************************
' Demonstrate the use of AddOLEDBSource by opening an ADO data source,
' adding the data source to the report, and then adding a field
' to the report that uses that data source. In this example, the
' OLEDB source in the VB Data Environment is used
'
Private Sub cmdOLEDB_Click()
Dim fld As FieldObject
' Add the datasource to the report
m_Report.Database.AddOLEDBSource DataEnvironment1.Connection1, "Customer"
' Add a new field object to the report and set the field object to use
' the new data source.
Set fld = m_Report.Section3.AddFieldObject("{Customer.Customer Name}", 0, 0)
LoadReport
End Sub' *************************************************************
' Load the Report in the viewer
'
Private Sub LoadReport()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = m_Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
cmdOLEDB.Enabled = False
cmdADO.Enabled = False
End Sub' *************************************************************
Private Sub cmdAbout_Click()
frmAbout.Show vbModal
End Sub' *************************************************************
Private Sub cmdExit_Click()
Unload Me
End Sub
首先感謝你,這種方法我也知道,問題是xtRpt.Database.AddADOCommand mCnn, mCmd 在引用8.0,8.5中都是正確的,引用9.0時,錯誤信息:creation feature not enabled,所有代碼都相同,而且原有的報表已經改為9.0報表,請李大俠幫兄弟看看:)
mCnn:ADO.Connection
mCmd:Ado.Command