Solved

Error 20599 in vb

Posted on 2003-11-28
12
3,255 Views
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

crp.connect="DSN=ADRIAN;UID=sa;PWD=;DSQ=Shipping"

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?

thnx

0
Comment
Question by:biao81
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9838465
0
 

Accepted Solution

by:
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
0
 

Author Comment

by:biao81
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
crystalreport.action=1
crystalreport.printerselection


anyone pls advises
0
 
LVL 100

Expert Comment

by:mlmcc
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.

mlmcc
0
 

Author Comment

by:biao81
ID: 9854698
what is the name of the event then? i couldn't find it
0
 
LVL 100

Expert Comment

by:mlmcc
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?

mlmcc
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:biao81
ID: 9856328
I believe there is no such event.

I am using OCX
0
 
LVL 100

Expert Comment

by:mlmcc
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.

mlmcc
0
 

Expert Comment

by:yadav_surender
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
DlgCmd.ShowPrinter

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


Cheers
0
 

Expert Comment

by:sr_haneef
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=209.237.13.174;Initial Catalog=HerbalAdvisor;User ID=sa;Password=z4327928sIERRA99;"
    CrystalReport1.DiscardSavedData = True
    CrystalReport1.Action = 1

Can anybody help regarding this problem its very urgent.


0
 

Author Comment

by:biao81
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.
0
 
LVL 100

Expert Comment

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

mlmcc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now