cancel
Showing results for 
Search instead for 
Did you mean: 

The dreaded "database error 4060"

anders_gustafsson
Participant
0 Kudos

Hi!

I ran into this at a customer's site and googled a lot, but found precious little info. Scenario is this: Old version of app was CR9. New version of app is CR XI R2 Sp6, .NET. App is 32-bit. Old development environment was XP against an Access database. Customers are either Access or MS SQL Server. New development environment is Win7 64-bit.

Only one customer got that 4060 error. He was on Xp 32-bit. Only two reports exhibited the error and I found out that I had changed the report database from the default access one to a file dsn that pointed to a SQL database whilst fixing some bugs.

Changing the report database to a system DSN that pointed to a SQL database did not fix the problem, but changing it to an Access database DSN did?

So what fixed the problem was to open the report, Database, Set database (Second menu item from top) and point to another DSN. Save report. Copy to client PC and it now reported correctly on that machine, against a SQL database.

What puzzles me is why it did this? Ie the app itself changes the database connection when running the report, yet the old DSN mattered? The report is NOT set to save data with the report.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Anders

Hard to say. Any number of variables (or combination thereoff) could have been the cause. E.g.;

1) 32 bit vs 64 bit DSN (There are two versions of the ODBC on a 64-bit server.)

2) DB client

3) Never use file DSN - always use System DSN with CR

4) Looking up the error in the database documentation may have also helped:

Error 4060 - Server rejected the connection; Access to selected database has been denied.

E.g.; there may have been lack of execute permissions on some object in the SQL db and not the Access db(?)

And so on...

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

anders_gustafsson
Participant
0 Kudos

"Error 4060 - Server rejected the connection; Access to selected database has been denied."

Ah.. So the error is from SQL Server and not CR. Should have guessed that. Now I know what to look for next. It cannot have been a permission error though as the same error happened if logged in as 'sa'

Most likely a 64/32-bit thing though.

I know about the file DSN stuff and CR, so that is why the app will create a system DSN programmatically, just for CR if one does not exist. Interestingly enough did it not work if I saved the rpt file with a selected database as a SQL Server system DSN, but it did work if I saved the RPT with a selected database as an Access system DSN.

What happened in this case was that I had connected the report (in designer) to a particular database, as a troubleshooting measure, and forgot to switch back to the "model" one. Apparently does CR save something in the RPT file and apparently does that not get cleared out when you select a database from within the app.

Anyway. It works now and reason I posted here is that I found tons of similar questions on the web, mainly in other forums, such as the M$ ones, so I though posting this might help someone if they run into the same problem.

.


		bool rc = CheckDatasource(dsn);
		if(!rc)
		{
			rc = SQLConfigDataSource(NULL,ODBC_ADD_DSN, theApp.m_DatabaseDriver, parms);
			if(!rc)
			{
				message.Format("Kunde inte skapa datakällan %s", dsn);
				AfxMessageBox(message);
				return false;
			}
		}
		ss_dsn = gcnew String(dsn);
		ss_database = gcnew String(theApp.m_DatabaseDatabase);
		ss_user = gcnew String(theApp.m_Anvandarnamn);
		ss_pw = gcnew String(theApp.m_Losen);
		crConnectionInfo->ServerName = ss_dsn;				// Needs to be a 32-bit datasource created with C:WindowsSysWOW64odbcad32.exe
		crConnectionInfo->DatabaseName = ss_database;
		//
		crConnectionInfo->UserID = ss_user;
		crConnectionInfo->Password = ss_pw;
		//
		// Trusted connection?
		//
		if (theApp.m_DatabaseTrusted) crConnectionInfo->IntegratedSecurity = true;
		break;
	}
	//
	//Get the table information from the report        
	crDatabase = m_Report->Database;
	crTables = crDatabase->Tables;
	//Loop through all tables in the report and apply the connection
    //information for each table.
    for (int i = 0; i < crTables->Count; i++)
	{
        crTable = crTables<i>;
	crTableLogOnInfo = crTable->LogOnInfo;
        crTableLogOnInfo->ConnectionInfo = crConnectionInfo;

	crTable->ApplyLogOnInfo(crTableLogOnInfo);
	}
	return bFileLoaded;
.

Edited by: Anders Gustafsson on Jan 31, 2012 6:41 PM

Edited by: Anders Gustafsson on Jan 31, 2012 7:24 PM

former_member183750
Active Contributor
0 Kudos

Hello Anders

Many thanks for posting your solution. There is never enough of those - always good to have all kinds of ways of looking at things.

Have a great day,

- Ludek

Answers (0)