Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to connect; incorrect log on parameter

Status
Not open for further replies.

smrati

Programmer
Jun 26, 2003
9
IN
I am using VB 6 and Sql server in my application.
I created reports using Crystal report version 4.6.1.0

My report is working fine when i call it in VB without using any selection formula.
EG
If the code is
Private Sub Command2_Click()
CrystalReport2.Action = 1
(the statement CrystalReport2.PrintReport also works similarly)
End Sub

This code works fine to display the report

BUT....
When i use a selection formula to facilitate parameter passing in Crystal report ,Report is not displayed.

EG:
if the code is as follows:

Private Sub Command2_Click()
CrystalReport2.SelectionFormula = "{OPDpatient_transaction.OPDregno} = " & Text1.Text
CrystalReport2.Action = 1

(here the statement CrystalReport2.PrintReport doesnt show following error but report is not displayed)

End Sub


Then there is an Run time error:
error no:20536
Unable to connect ;Incorrect Log on parameters


I have also tried Replaceselectionformula..it also gives same error

Please i am too much in problem.Can any one help me out?

Thanks a lott



 
I've been having that same error message.

A couple of things.
1) I don't think your problem has to do with passing in parameters to crystal report. I have been able to pass in parameters fine an still get the error.

2) I'm using crystal reports 9 with vb.net. and as a web application. I'll post my code tomorrow and it might have to be modified for your needs.

I've been told that the error "unable to connect; incorrect log on parameter" is caused because my sql server was on a different machine, and the the local ASP.NET account was trying to log on to that machine and doesnt have access. You need to pass on a connection string with a valid userID and password plus database (something like my other post titled "connecting to sql server")

The sure way to see if you are passing in parameters correctly (rather than worrying about database connections) is to setup a local databse using MSAccess or ur slq server on the same machine as your application.

Hope this helps
 
Thanks For ur reply.
But I am developing project on single machine.
So as u said i have the sqlserver set up on my local machine only.
The problem is still there
I thot that perhaps it is some problem in passing parameters coz the report doesnt have any connection problem and displays correctly ,if i dont pass any parameter.
Can u please help me out?

Please tell me the code using which you were able to pass parameters correctly.I will check if it works with my thing.
Thanks
 
Below is code to pass in parameters to a crystal 9 report viewer from VB.net. You essentially have to create parameter fields and their values, add the values to the fields, and then add the fields to field collection, and add the that collection to the report so the report knows which paramters to look for.

Step 9 in connection is the part that gives me trouble also, but I'm pretty sure the rest of the code is fine.

----------
Public Sub setParameters()

Dim ParameterFields As CrystalDecisions.Shared.ParameterFields

Dim myParameterName1 As CrystalDecisions.Shared.ParameterField

Dim myParameterValue1 As CrystalDecisions.Shared.ParameterDiscreteValue

'Step 1: Create a new ParameterFields collection
ParameterFields = New CrystalDecisions.Shared.ParameterFields()

'Step 2: Create the new ParameterField object
myParameterName1 = New CrystalDecisions.Shared.ParameterField()

'Step 3: Assign the ParameterFieldName property
myParameterName1.ParameterFieldName = "parmeter1OfReport"

'Step 4: Create a ParameterValue object.
myParameterValue1 = New CrystalDecisions.Shared.ParameterDiscreteValue()

'Step 5: Assign a value to the object
myParameterValue1.Value = "myValue"

'Step 6: Add the ParameterValue object to either the
'CurrentValues or DefaultValues collection
myParameterName1.CurrentValues.Add(myParameterValue1)

'step 7: Add the ParameterField object to the ParameterFields collection
ParameterFields.Add(myParameterName1)

'Step 8: Assign the ParameterFields collection to the viewer
CrystalReportViewer1.ParameterFieldInfo = ParameterFields

'Step 9 connect to database
'code not successful at this point.


'Step 10: Preview the report
'Dim myReport As New rptName()
CrystalReportViewer1.ReportSource = myReport
CrystalReportViewer1.RefreshReport()

End Sub

----------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top