具体代码如下,现在每次打开报表都要求输入密码,有什么办法可以取消,请各位赐教 ---数据库连接 Public gCnnERP As String = "Data Source=192.168.1.1;initial Catalog=ERP;User ID=sa;password=admin"Public Function GetDataSet(ByVal gCnn As String, ByVal sql As String, Optional ByVal TmpTable As String = "TmpTable") As DataSet
Dim objAdapter As SqlDataAdapter
Try
objSqlConnection = New SqlConnection(gCnn)
objAdapter = New SqlDataAdapter(sql, objSqlConnection)
GetDataSet = New DataSet
objAdapter.Fill(GetDataSet, TmpTable)
objAdapter = Nothing Catch ex As Exception
MsgBox("數據處理錯誤" & Err.Number & ":" & Err.Description)
End Try---打开报表Dim strSql As String
Dim MyDataSet As DataSet
Dim f_frmReport As New frmReport
Try
Dim MyReport As New CrWarehouseTwoSendA4
MyDataSet = GetDataSetOleDB(gCnnERP, strSql)
MyReport.SetDataSource(MyDataSet.Tables(0)) With f_frmReport
.CrystalReportViewer1.ReportSource = MyReport
.Text = "發料單"
.Show()
End With
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim objAdapter As SqlDataAdapter
Try
objSqlConnection = New SqlConnection(gCnn)
objAdapter = New SqlDataAdapter(sql, objSqlConnection)
GetDataSet = New DataSet
objAdapter.Fill(GetDataSet, TmpTable)
objAdapter = Nothing Catch ex As Exception
MsgBox("數據處理錯誤" & Err.Number & ":" & Err.Description)
End Try---打开报表Dim strSql As String
Dim MyDataSet As DataSet
Dim f_frmReport As New frmReport
Try
Dim MyReport As New CrWarehouseTwoSendA4
MyDataSet = GetDataSetOleDB(gCnnERP, strSql)
MyReport.SetDataSource(MyDataSet.Tables(0)) With f_frmReport
.CrystalReportViewer1.ReportSource = MyReport
.Text = "發料單"
.Show()
End With
Catch ex As Exception
MsgBox(ex.ToString)
End Try
所以你要看看GetDataSetOleDB方法是否没有指定数据库的用户名和密码!
Public gCnnERP As String = "Data Source=192.168.1.1;initial Catalog=ERP;User ID=sa;password=admin"Public Function GetDataSet(ByVal gCnn As String, ByVal sql As String, Optional ByVal TmpTable As String = "TmpTable") As DataSet
Dim objAdapter As SqlDataAdapter
Try
objSqlConnection = New SqlConnection(gCnn)
objAdapter = New SqlDataAdapter(sql, objSqlConnection)
GetDataSet = New DataSet
objAdapter.Fill(GetDataSet, TmpTable)
objAdapter = Nothing Catch ex As Exception
MsgBox("數據處理錯誤" & Err.Number & ":" & Err.Description)
End Try