Hi vineet,
You don't specify which version of VB you're using, but I'm guessing that it's either the 2003 or 2005 .NET version.
Unlike earlier versions of VB, yoiu have to log in to each table used in the report. Brian Bischof gives a nice explanation in his book "Crystal Reports .NET Programming" in chapter 17 and includes a coding example (17-11). see Logging On with the ReportDocument object.
If you can't get ahold of a copy of the book (and it's worth gettting) try what I've added below.
Here is an example that I used in one of my apps.
' Set the ConnectionInfo properties for logging on to the Database
' If you are using ODBC, this should be the DSN name NOT the physical server name.
' If you are NOT using ODBC, this should be the physical server name
'
With crConnectionInfo
.ServerName = SrvName
' If you are connecting to Oracle there is no DatabaseName. Use an empty string.
.DatabaseName = ""
.UserID = LogonID
.Password = Password
End With
'
' This code works for both user tables and stored
' procedures. Set the CrTables to the Tables collection of the report
CrTables = crReportDocument.Database.Tables
' Loop through each table in the report and apply the LogonInfo information'
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
If Not CrTable.TestConnectivity() Then
MsgBox("Invalid Credentials for Table: " & CrTable.Name & ".Table Login Failed")
End If
Next