Error 20599 in vb

Posted on 2003-11-28
Last Modified: 2012-05-04
I am getting this error while i'm trying to set the connection string of crystal report the error msg is error '20599' Cannot open SQL server.

Actually I have met this problem long time ago, but I have choose to avoid it by doing crp.connect="PWD="
Well, in the end i still need to programmatically set my connection string, my original setting is like


May I know is there anything wrong with this, cos i keep getting this error, and I am sure that all the parameter is correct because i have successfully use same parameter to do my database connection for ADODB connection which is

"Provider=SQLOLEDB.1;Persist Security Info=False;" & _
                           "User ID=sa;password=ttnika;" & _
                           "Initial Catalog=Shipping" & ";Data Source=ADRIAN"

So, any expert out there please help me, cos i'm desperate searching the internet whole day and find no solution.

Secondly, I would like to know also, how can I programmatically use vb syntax to set the printer for crystal report?


Question by:biao81
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1

Accepted Solution

yadav_surender earned 50 total points
ID: 9841788
Instead of passing provider setup you can use this syntax

Report.database.setdatasource recordset,3,1  
and for printer setup you can pop up the printer window by giving this command
report.printersetup true

Author Comment

ID: 9849045
I solve the error open sql server, it's actually a careless mistake whereby i put my DSN name wrongly. well for report.printersetup,
it's actually report.printerselection, it works, so i think i will give the point to yaday_surrender for the printer part. but before this,
can u teach me how to pop up the printerselection only when user click on the little print button, cos currently, mine pop up whenever i
view a report even b4 i click on print.

what i do now is

anyone pls advises
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 101

Expert Comment

ID: 9854425
To avoid the printer setup screen showing before you click the print button, put the code in the print button click event not in the code that calls the report.


Author Comment

ID: 9854698
what is the name of the event then? i couldn't find it
LVL 101

Expert Comment

ID: 9855031
I believe it is PrintButton_Click

I don't have an appropriate CR & VB here to check it.

What code are you using to call the report?

What method OCX, RDC?


Author Comment

ID: 9856328
I believe there is no such event.

I am using OCX
LVL 101

Expert Comment

ID: 9863689
Sorry missed the .action = 1 which is the OCX.  You are correct the OCX doesn't have events.

As I recall the OCX has a PRINTERSELECTION button.  Enable that and tell the user to click it first, just as you have to from WORD with FILE--> PRINT rather than hitting the print button.


Expert Comment

ID: 9873042
If it is not solved your problem of printer selection then you can use this way:
First take a common dialog control with components.  Name it DlgCmd
write button_click event
on error resume next
printer.setdefault=true  'For default printer
DlgCmd.flag=&H8 or &H100000

'Common dialog control is under projects->components->Microsoft Common controls


Expert Comment

ID: 10274368
I am getting this error while i'm trying to set the connection string of crystal report the error msg is error '20599' Cannot open SQL server.
Crystal Report  version is 8.5.

The following is the code written in VB

CrystalReport1.ReportFileName = "c:\report1.rpt"
CrystalReport1.Connect = "Provider=sqloledb;Data Source=;Initial Catalog=HerbalAdvisor;User ID=sa;Password=z4327928sIERRA99;"
    CrystalReport1.DiscardSavedData = True
    CrystalReport1.Action = 1

Can anybody help regarding this problem its very urgent.


Author Comment

ID: 10276846
hey, sr_haneef. initially this is the problem i post in this topic, but sounds like now I'm the one trying to help u, LOL.
You can try this, open ur report with crystal report itself. On the Menu, go to Database --> Set Location, and then for every table in the database,
remove the prefix of the table eg. if you see dbo.TableName, make it TableName. Remember to do it for every table. then click Done.
Save ur work, and it should solve ur problem.
LVL 101

Expert Comment

ID: 10277670
It is generally expected for you to open your own questions.


Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question