主题:打开水晶报表,提示要输入报表参数与数据库用户名、密码。这个问题如何解决?谢谢!
1、当打开水浏览时,提示要输入报表参数与数据库用户名、密码。这个问题如何解决?谢谢!
注:CrystalReport1 报表名
Dim oRpt As New CrystalReport1
Dim SQL_CONNECTION_STRING As String
SQL_CONNECTION_STRING= "server=192.168.0.18;database=HSERP;uid=sa;pwd=sa"
Dim scnnProduce As New Data.SqlClient.SqlConnection(SQL_CONNECTION_STRING)
scnnProduce.Open()
'定义命令对象, 并使用储存过程
Dim myCommand As New SqlClient.SqlCommand
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "sp_WorkStocks"
myCommand.Connection = scnnProduce
'定义一个数据适配器, 并设置参数
Dim myDapter As New SqlClient.SqlDataAdapter(myCommand)
myDapter.SelectCommand.Parameters.Add("@WorkName", SqlDbType.VarChar, 20).Value = Trim(txtDepart.Text)
myDapter.SelectCommand.Parameters.Add("@Cwname", SqlDbType.VarChar, 20).Value = Trim(txtCwname.Text)
myDapter.SelectCommand.Parameters.Add("@StartDate", SqlDbType.DateTime, 10).Value = Trim(txtSDate.Text)
myDapter.SelectCommand.Parameters.Add("@EndDate", SqlDbType.DateTime, 10).Value = Trim(DateTimePicker2.Text)
myDapter.SelectCommand.Parameters.Add("@MatCode", SqlDbType.VarChar, 20).Value = Trim(txtMatcode.Text)
'定义一个数据集对象, 并填充数据集
Dim myDataSet As New DataSet
Try
myCommand.ExecuteNonQuery()
myDapter.Fill(myDataSet, "sp_WorkStocks")
Catch ex As Exception
End Try
oRpt.SetDataSource(myDataSet)
MyReportForm.CRVsotck.ReportSource = oRpt
MyReportForm.CRVsotck.DisplayGroupTree = False
注:CrystalReport1 报表名
Dim oRpt As New CrystalReport1
Dim SQL_CONNECTION_STRING As String
SQL_CONNECTION_STRING= "server=192.168.0.18;database=HSERP;uid=sa;pwd=sa"
Dim scnnProduce As New Data.SqlClient.SqlConnection(SQL_CONNECTION_STRING)
scnnProduce.Open()
'定义命令对象, 并使用储存过程
Dim myCommand As New SqlClient.SqlCommand
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "sp_WorkStocks"
myCommand.Connection = scnnProduce
'定义一个数据适配器, 并设置参数
Dim myDapter As New SqlClient.SqlDataAdapter(myCommand)
myDapter.SelectCommand.Parameters.Add("@WorkName", SqlDbType.VarChar, 20).Value = Trim(txtDepart.Text)
myDapter.SelectCommand.Parameters.Add("@Cwname", SqlDbType.VarChar, 20).Value = Trim(txtCwname.Text)
myDapter.SelectCommand.Parameters.Add("@StartDate", SqlDbType.DateTime, 10).Value = Trim(txtSDate.Text)
myDapter.SelectCommand.Parameters.Add("@EndDate", SqlDbType.DateTime, 10).Value = Trim(DateTimePicker2.Text)
myDapter.SelectCommand.Parameters.Add("@MatCode", SqlDbType.VarChar, 20).Value = Trim(txtMatcode.Text)
'定义一个数据集对象, 并填充数据集
Dim myDataSet As New DataSet
Try
myCommand.ExecuteNonQuery()
myDapter.Fill(myDataSet, "sp_WorkStocks")
Catch ex As Exception
End Try
oRpt.SetDataSource(myDataSet)
MyReportForm.CRVsotck.ReportSource = oRpt
MyReportForm.CRVsotck.DisplayGroupTree = False