简体   繁体   中英

Not able to Connect to Crystal Reports 2008

I'm exporting a crystal report 2008 to pdf in C#.

The crystal report is connected to sql server 2008 using odbc.

I want to deploy this in a different system. it works if the db name is the same.

Is there a way to supply the db name dynamically. I tried

repDoc.SetDatabaseLogon(db_username, db_password,server,db);

and it fails with the error below

    Logon failed.
Details:  [Database Vendor Code: 18456 ]Database Connector Error: ' [Database Vendor Code: 18456 ]'Failed to open the connection.
Details:  [Database Vendor Code: 18456 ]Error in File denial_completed_letters {84E1BDEF-C60B-46E1-9080-77F699692270}.rpt:
Unable to connect: incorrect log on parameters.
Details:  [Database Vendor Code: 18456 ] 

Good news / bad news: the bad news is that you can't use SetDatabaseLogon to change the db name. The good news is that you can use another function, ApplyLogOnInfo to do that:

http://msdn.microsoft.com/en-us/library/cc411352(v=VS.90).aspx http://msdn.microsoft.com/en-us/library/ms226184(v=VS.90).aspx

Just get the logon info from the Table.LogOnInfo constructor, change the values, and call ApplyLogOnInfo.

For Windows 7, try to install your application by Run as Administrator and set the run as administrator compatibility to the exe. To set Run as Administrator compatibility to the exe right click on the exe then go to properties -> compatibility, check the Run as administrator checkbox and click OK.

Sounds like your database server isn't configured for both NT and SQL authentication. or you can use sa user that have access over target database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM