Invalid File DSN - VB6 Crystal Viewer Application

I am trying to connect my reports with VB6 using SETLOGONINFO function. The reports are originally using File DSN ODBC connection to a bunch of text files . Here is my line of code:

m_objCRReport.Database.Tables(1).SetLogOnInfo "", "", "", ""

I did not specify any server name, because the reports look at the same ODBC. so, I don't need to change the server during runtime. Basically, I want my viewer open the reports and being able to refresh, nothing complicated.

When I use this line of code, I get an "Logon Failed. Details: HY000: General Error: Invalid File dsn "DSN name"

Then when i change the code to m_objCRReport.Database.Tables(1).SetLogOnInfo "Location and name of File DSN.dsn", "", "", ""

Then I do get blank reports. Static stuff is in the report (such as logos, text files etc) but the data is blank.

The ODBC File DSN sits in the server.
The text files that File DSN looks sit on the server.

I am told that I have administrative privileges, so I don't think network connection is a problem.
The computer has crystal, can't be DLL issue.

Crystal is version 8.5

What is my problem? Please help .
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you still need to specify the database name (second parameter)

have you tried hardcoding the values?

SetLogOnInfo is used to establish a connection or change a connection source.  If you established that in the report file, you shouldnt have to use SetLogOnInfo.

MurattiAuthor Commented:
when I don't set anything in the code (I mean if I don't use setlogoninfo), then again I get the

invalid file dsn error

My assumption also was that since the reports know where to look I don't have to specify it. But could not get past this error.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

MurattiAuthor Commented:
What I don't understand is, once I open a report, why can't the report find its source without me telling it again in the code where the source is?
The report somehow stores the information it was built with.  So long as none of that changes the report should run.  If you change the DSN then the report is lost because it doesn't know which database in the DSN to use.

MurattiAuthor Commented:
You are right, I am not trying to change the dsn and the reports should run correctly. But my problem is they don't. They give this invalid file dsn error. Should I completely remove the setlogoninfo function?
>Should I completely remove the setlogoninfo function?

thats what I was trying to say above. I dont think you need it. it should just inherit the properties from the .rpt file.  You may need to turn off prompting as well though.

ReportObject.EnableLogonPrompt = false

MurattiAuthor Commented:
ok, I removed that line, and I am still getting the same invalid file dsn error.

I could not write ReportObject.EnableLogonPrompt = false because, I don't get that property in VB. the closest property is "EnableParameterPrompting".

Any Idea?
ahh yeah are using the RDC.  do the same with EnableParameterPrompting.
MurattiAuthor Commented:
Still getting the same error. Invalid File DSN.

Assuming the code is right this way (removing setlogoninfo, and adding enableparameterprompting), could it be something related with network? The reports themselves and the dsn file they are looking at and the text files the odbc is pointing at, they all are in the server. The computer I am running the application, is connected to the server. And as far as I am told, it has all the admin privileges.

Could this be a problem?

as long as you can access the shared drive on the server with the username and password for your app (IUSER if its set up with default) there should be no issue with network access.  Perhaps its just a simplistic syntax error in the dsn or in the report.

>Open the Report
>click on the "Database" menu
>select "Verify Database"
>chick ok for each resulting message box

all the message boxes should say something ot the effect of, "The Database file "tabe_name"has changed. Proceeding to fix up the report".

>save the report and close it
>try running the app again.

MurattiAuthor Commented:

when I do that, it says to me "the database it up to date".

and yes, I can access the server without any problems.

One other interesting note is:

Let's say, I create a new dsn and set the location of the report point to the new dsn. And then in the code, I use setlogoninfo pointing to the original (the one the report was using before I changed it to the new dsn) dsn file, then it is working fine. but this does not make sense to me.

Any ideas?

when you created a new dsn did you give it a diffrent name?
and if you take out setlogoninfo what happens?

did you test it with the old dsn after you ran the "Verify database" task?
MurattiAuthor Commented:
yes, when I created the new dsn, I gave it a different name.

when I take out setlogoninfo, no matter what (if the report points to the old or new dsn) I still get the Invalid file dsn error.

yes, I tested the with the old dsn after verifying the database.

mnye, I appreciate your support. I really need to get this problem solved.
explicitly define all parameters for setlogoninfo.

also, when you make a change to code, helps me understand exsactly what you're doin'

glad to help
MurattiAuthor Commented:
Here is my code, maybe there is something in the code that you may notice:

Public Sub viewReport()
    Set m_objCRReport = m_objCRApp.OpenReport(m_strReportName)
    m_objCRReport.EnableParameterPrompting = False
    m_objCRReport.Database.Tables(1).SetLogOnInfo "\\u4\Projects\SRE_Reports\Zainet Reports.dsn", "", "", ""
   ' m_objCRReport.Database.Tables(1).SetLogOnInfo "", "", "", ""
    CRViewer.ReportSource = m_objCRReport
    CRViewer.EnableRefreshButton = True
    CRViewer.EnableExportButton = True
    While CRViewer.IsBusy
    CRViewer.Zoom 75
    Me.Caption = m_strReportName

    CRViewer.EnableCloseButton = True
End Sub
Can you open the report from Crystal with the new DSN?

MurattiAuthor Commented:
I can open the report after changing the dsn (database->set location) fine. But it required me to map the fields though.
Have you considered that maybe Crystal has a problem with the UNC?  If you map a shared drive to \\u4\Projects and then set your location as say S:\SRE_Reports\Zainet Reports.dsn does that resolve it?
MurattiAuthor Commented:

I opened a report in crystal, and converted its database driver to psodbc.dll (it was already that but I redid it), then it took me to a screen where I specified my dsn again.

Then refreshed and saved the report. Now I have a strange error trying to connect to the report with my app:


I did a small research and found an explanation like this for this error:

The keyword-value pair for the DRIVER keyword contained a syntax error.

I have no idea about this.
Hmm, never heard of this error, but a quick search implies that the dsn is incorrect, that the driver indicated in the dsn has an incorrect value.

Can you recreate the DSN from scratch?  Could it have gotten corrupted with all your testing.
haveyou tried creating a System DSN instead of a FIle DSN?

MurattiAuthor Commented:
when I create a system dsn, then I don't know how to use Setlogoninfo method. Because i can't say where the dsn is located.

How do I do that?
when you use a system dsn, you dont have to specify location.

let me know if you need some code examples.  there are a couple in that article.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To add to Matt's stuff,  we use a User DSN for our reporting to a SQLServer database, the login information is called on the application object:  Not sure if this will help in your case, but here's what works well for us.

We use a UserDSN because the ODBC can be written/verified programmatically to the Registry.

  If mobjApplication Is Nothing Then
    Set mobjApplication = New CRAXDRT.Application
    mobjApplication.LogOnServer "p2sodbc.dll", 'UserDSNName', DatabaseName, User, Password
  End If

I don't use SetLogonInfo under any reports.

You should only ever have one open/loaded mobjApplication though, if you open more than 5 instances you will run into Crystal Licensing errors.  

Also, make sure that you clean up the Application object when you shut down your exe or you may get GPF's on close.
MurattiAuthor Commented:
ok I used a system dsn

m_objCRReport.Database.Tables(1).SetLogOnInfo "systemDSN name", "Location of text files where system dsn is pointing at", "", ""

Now my error is,

This group section cannot be printed because its condition field is nonexistent or invalid. Format the section to choose another condition field.

However, this report opens up without any problems with crystal.
Try verifying the database

Open the report

When you open the report in Crystal are you usingthe same data connection?

MurattiAuthor Commented:

I think I am getting closer to solve my problem. My machine has two crystals one is crystal reports 8.5 and the other is Crystal developer version 9.

So, in my vb application, I accidentally included references for Crystal Reports 9 ActiveX Designer Run Time Library. But the reports we were trying to access, are built with Crystal Reports 8.5. So I changed this runtime library to 8.5. Now when I try to open the reports with a machine installed with crystal, then I don't have problems. but without crystal I am getting the "server has yet not been opened"

I think all the problems I mentioned before was because of this library confusion problem. Any thoughts?
As added in your other question
Could very well be.  CR has a habit of changing the interface between versions.

The server not opened yet is generally a missing dll or lack of permissions

There ar etoo many for me too search through
Here is the result of my search of the CR site

Adding on mlmcc's answer, I encountered that often in my product when the report could not connect through the DSN to the server because either the server name was wrong or the password was invalid.

Can you open the DSN on the machine without crystal and test the connection with the test connection button?

MurattiAuthor Commented:
"server has not yet been opened" error, I solved through using UNC for database path. In other words, the server was mapped in the testing computer, and that's why the report could not find its source.
thanks, kathmacmahon.

But "server has not yet been opened" error still exists on the client side. I checked if there was any mapping, but there is none.

Also, the interesting note is, when you access a report built from a native access database connection(sitting on the server), then it does not give an error. But the error persists for Dsn connections.

Here are the details of "set location" of a sample report.

Table : \\U4\Projects\ZN Reports\AUDS_CPTY.rpt (it is not mapped)
Server type: FDSN - Zainet Reports.dsn
Server name: Zainet Reports.dsn
Database: \\U4\Projects\SRE_Reports\Zainet Reports.dsn
User Id: (empty)

So everything looks good to me, but somehow the viewer application can't access the report. "server has not yet been opened"
MurattiAuthor Commented:

I could not see any test connection button in my ODBC administrator. Where is it available?
So you are still using a File DSN?  I've not worked with these before, usually use a UserDSN, but if you got to your fileddsn list and click configure -> run through the property pages to the end and there's a 'test data source' button.

MurattiAuthor Commented:
Property Pages?

The only thing I see is a "Define Format" option, which takes you to the files that are being connected to through the DSN. When you click a file, you can "Guess" it in there. Is this what you meant with "test data source"

Oh!, right you're using flat text files, that driver probably doesn't offer a test connection choice.

I think you should follow mlmcc's advice and follow the links he offered, you're going to have to follow Crystal's troubleshooting techniques.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.