Link to home
Start Free TrialLog in
Avatar of UPRRDevelopers
UPRRDevelopers

asked on

Error 20599 Cannot Open SQL Server via VB

I have a VB app which I use to call a Crystal Report.  This is the code:

CrystalReport1.ReportFileName = "C:\Reports\vbdata\Open to Close.rpt"
CrystalReport1.DiscardSavedData = True
CrystalReport1.Connect = "DSN= MyData; UID = ; PWD = "
CrystalReport1.Destination = crptToWindow
CrystalReport1.Action = 1

I have an Access Database as the source for the data.  I can run the report within Crystal with no problems.  When I run it via this VB interface, I get 20599, Cannot Open SQL Server.  I have read numerous links on the net, but none have helped.  I have tried about every possible iteration of the Connect statement above that I can think of.  No password is required on the Access file.
Avatar of abdulhameeds
abdulhameeds
Flag of Saudi Arabia image

IN THE FIRST
USING CRYSTAL REPORT  WITH MS ACCESS2000 + YOU HAVE TO MAKE ODBC
GOTO ADMINISTRATIVE TOOLS
DATA SOURCES (ODBC)
THEN ADD ---> MICROSOFT ACCESS DRIVER ( *.MDB) THEN TYPE YOUR ODBC NAME ( DB1) FOR EXAMLE
SELECT THE DATABASE PATHH THEN
OK   OK

THEN YOU AVE TO WRITE THIS CODE
CrystalReport1.ReportFileName = " & APP.PTH &  " & "\YOURREPNAME.RPT"
CrystalReport1.DiscardSavedData = True
CrystalReport1.Connect = "DSN= YOUR ODBC NAME"
CrystalReport1.Destination = crptToWindow
CrystalReport1.Action = 1

I HOPE IT WILL WORK

THIS ERROR MEAN THAT YOU HAVE TO CREATE ODBC DATA SOURCE COZ U R USING ACCESS 2000 OE XP OR 2003 OR 2007


BEST REGARDS

untitled.bmp
Avatar of UPRRDevelopers
UPRRDevelopers

ASKER

Thanks for the detailed instructions, but I already tried that.  I created the Data Source using Microsoft Access Driver and tied it to my MDB file, but I still get the error.  I called the DSN "OpenData" and referenced it as shown below.  That didn't work, so I've been trying other stuff.

CrystalReport1.Connect = "DSN= OpenData"
ok now if you are sure that you create it
then open the report -----
then select from the menu bar
data base
there is ----set location ----
see down ( location ) ist the truth path
and for sure you can set the path again by select (Set location )
then after that
very data base

now try this

    rpt.Destination = crptToWindow
    rpt.Connect = "dsn = OpenData"
    rpt.WindowState = crptMaximized
    rpt.DiscardSavedData = 1
    rpt.ReportFileName = App.Path & "\Report2.rpt"
    rpt.Action = 1


untitled.bmp
Open to Close.rpt

if you have spaces in ur report name move the spaces and let it one word
I removed the spaces, but it didn't change anything.  When I followed the other steps, the error changed to Run time 20533, "Unable to open database".  Thanks for your attempts ... it's appreciated.
ok  this good sighn lol
now try the following
make new report
them put any field inside the report without design just for test
and call the report from vb and put the reports in the same path for your system

it will give you the same error ?
please post me the connection string for you data base
 ( btw what u r using access version?)

waiting your notes
I tried your steps, and I'm back to the "Cannot open SQL Server" error.   We are using Access 97 / VB 6 / Crystal Reports 8.0.  Yeah, I know ... old versions.  I'm strongly considering an upgrade to Crystal Reports to 11 so I can use the RDC instead.
ok now i know what is the problem ok i will post the solution today
all the problem is with your version

in access 97 you dont need to make odbc
this is the problem
you have two choice
1-change your database to access 2000+

or just wait me today i will post  u the code
for 97 data base


th e report connect direct to data base with out ODBC
Avatar of Mike McCracken
You can use the RDC in CR8  Also you can directly connect to Access without needing an ODBC connection.

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of abdulhameeds
abdulhameeds
Flag of Saudi Arabia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mimcc, that's the strange part.  Everything was working fine WITHOUT an ODBC connection to the database.  It ran fine for at least two weeks.  Then all of the sudden, "Cannot Open SQL Server".  I read several posts on the net that suggested creating an ODBC connection.  I did that, and ironically, it worked fine... again, for about a week, then the error returned, and here I am now.

Abdul, I'm checking out your posts now... thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i swaer i do it and its work with me
if there is possible to add me and remote access from msn messenger
plz add me <IM account removed mlmcc zone advisor>
Well get this.  I've been asking for Crystal XI now for months, and I finally got it installed yesterday.  I'm going to try this through RDC and see what luck I have with that.  Thanks for your help.  I'm giving Abdul 400 points for sticking with me and mlmcc 100 for his help also... thanks.