Solved

Error 20599 in vb

Posted on 2003-11-28
12
3,257 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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. …
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 …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

947 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