“数据库登录失败”从VS 2008升级到VS 2010后出现错误 [英] "Database Logon Failed" error after upgrading from VS 2008 to VS 2010

查看:367
本文介绍了“数据库登录失败”从VS 2008升级到VS 2010后出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序是写在VS 2008 for .net 2,升级到VS 2010,并为.net 4。在这个应用程序是一个水晶报表。报告应该绝对没有数据库交互。我手动设置从我的项目中的一个对象的各种ITextObject字段。



示例:

  to =(CrystalDecisions.CrystalReports.Engine。 TextObject)crystalPrint.Section2.ReportObjects [tbName]; 
to.Text = visitor.first ++ visitor.last;

to =(CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects [tbCompany];
to.Text = visitor.company;

其中 visitor m从数据库中获取数据。



再一次,这个报告应该绝对没有数据库交互,然而,它却以某种方式认为它应该是一个数据库。



以下是相关的堆栈跟踪:
CrystalDecisions.ReportAppServer.DataSetConversion



编辑:当我调用 .PrintToPrinter(1,false,1,0);



* EDIT / UPDATE *
我插入app.config文件,我发现这个小块

 < startup useLegacyV2RuntimeActivationPolicy =true> ; 
< supportedRuntime version =v4.0sku =。NETFramework,Version = v4.0/>
< / startup>

在应用程序中打印报告。



更多的源代码:



  cryBadge crystalPrint = new cryBadge 
crystalPrint.ReportOptions.EnableSaveDataWithReport = false;

//注意:pi是用于查找打印机信息的内部对象。
crystalPrint.PrintOptions.PrinterName = pi.PrinterName;
numSize = pi.FindPaperSizeIndex(height,wid);
to =(CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects [tbName];
to.Text = visitor.first ++ visitor.last;

to =(CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects [tbCompany];
to.Text = visitor.company;
crystalPrint.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
crystalPrint.PrintToPrinter(1,false,1,0);


解决方案



我不得不在app.config文件中输入这段代码:

 < startup useLegacyV2RuntimeActivationPolicy =true> 
< supportedRuntime version =v4.0sku =。NETFramework,Version = v4.0/>
< / startup>

然后确保配置文件与.exe保持一致例如,如果应用程序名为TestApp1 ,在输出文件夹中应该有一个TestApp1.exe.config文件。该.config文件需要留在应用程序。


I have a app that was written in VS 2008 for .net 2, upgraded to VS 2010 and built for .net 4. In this app is a Crystal Report. There should be absolutely NO database interaction done by the report. I manually set the various ITextObject fields from one of the objects in my project.

Example:

            to = (CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects["tbName"];
            to.Text = visitor.first + " " + visitor.last;

            to = (CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects["tbCompany"];
            to.Text = visitor.company;

where visitor is the class that I'm pulling data from.

Again, there should be absolutely NO database interaction done with this report, and yet, it somehow thinks that it should be hitting a database.

Here's the relevant stack trace: CrystalDecisions.ReportAppServer.DataSetConversion

EDIT: It's blowing up when I call .PrintToPrinter(1, false, 1, 0);

*EDIT / UPDATE * I poked into the app.config file, and I found this little block

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

With that in the app, my report prints. With that commented out, it blows up.....

EDIT 3:

More source code:

 cryBadge crystalPrint = new cryBadge();
 crystalPrint.ReportOptions.EnableSaveDataWithReport = false;

 //NOTE: pi is an internal object used to find printer information.
 crystalPrint.PrintOptions.PrinterName = pi.PrinterName;
 numSize = pi.FindPaperSizeIndex(height, wid);
 to = (CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects["tbName"];
            to.Text = visitor.first + " " + visitor.last;

 to = (CrystalDecisions.CrystalReports.Engine.TextObject)crystalPrint.Section2.ReportObjects["tbCompany"];
 to.Text = visitor.company;
 crystalPrint.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
 crystalPrint.PrintToPrinter(1, false, 1, 0);

解决方案

Alright. Figured it out.

I had to enter in this block of code into the app.config file:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

Then make sure the config file stays with the .exe For example, if the app called "TestApp1", there should be a TestApp1.exe.config file in the output folder. That .config file needs to stay with the application.

这篇关于“数据库登录失败”从VS 2008升级到VS 2010后出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆