but you never close the connection.
this must occur on the second hot of the code. Your connection scope is global so each time your code is hit you are using the same instance of it. The first time it runs through, you set the connection string and open the connection. The second time it runs the connection is still open (very bad).
Your connection should be at the lowest scope possible. That's why you will usually see it in a 'using' block. This makes the connection scope even lower that the function itself.
Always close connections
Always dispose of connections
These are't just guidelines, it's the law! :Þ
Hope that helps ^_^
Andy
EDIT: updated with code
Option Explicit
Public Report As New CrystalReport1
Public Function printReport()
Dim strConnectionString As String
Dim rs As ADODB.Recordset
Dim strScript As String
strConnectionString = "Provider=SQLOLEDB............"
Using mvCn As New ADODB.Connection
mvCn.ConnectionString = strConnectionString
mvCn.CommandTimeout = 0
mvCn.CursorLocation = adUseClient
mvCn.Open
strScript = strScript & "SELECT * FROM employee" & vbCrLf
Set rs = mvCn.Execute(strScript)
mvCn.Close()
End Using
Report.Database.SetDataSource rs
Report.AutoSetUnboundFieldSource crBMTNameAndValue
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Set Report = Nothing
End Function