Private Sub Command1_Click(Index As Integer)
With cr1 'cr1为报表控件
.PrinterDriver = Printer.DeviceName
.DiscardSavedData = True
'-------------------------------------------------
'连接方式一
.Connect = "DSN = drugdb;UID =sa;PWD =;"
'连接方式二
.Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=evaluate;Data Source=SAMUNCLE"]
'连接方式三
Dim adocon As ADODB.Connection
Set adocon = New ADODB.Connection
adocon.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=drugdb;Data Source=SAMUNCLE"
adocon.ConnectionTimeout = 120
adocon.Open
'-------------------------------------------------
.Destination = crptToWindow '预览
.ReportSource = crptReport
.WindowHeight = Screen.Height
.WindowWidth = Screen.Width
.ReportFileName = App.Path + "\crystaltest47.rpt"
.WindowTitle = "标题"
.WindowState = crptMaximized '窗口最大化
.WindowLeft = 0
.WindowTop = 0
.Formulas(0) = ""
.Formulas(1) = ""
.Formulas(0) = "这是第一个参数!"
.Formulas(1) = "这是第二个参数!" & Chr(13) & Chr(10) & "我回行了"
.FetchSelectionFormula
.Action = 1
End With
本文地址:http://com.8s8s.com/it/it42049.htm