VS2010 Crystal报告要求输入用户名和密码 [英] VS2010 Crystal report ask for Username and Password

查看:87
本文介绍了VS2010 Crystal报告要求输入用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我正在开发一个桌面应用程序,我在其中创建了使用SQL-Server express 2008(内置VS2010)的水晶报表。它询问我不知道的用户名和密码。我该怎么办?



我在谷歌和这里搜索过,但我没有使用过。







提前致谢。

Hello friends,
I am developing an desktop application in which i have created crystal report which uses SQL-Server express 2008 (which comes built-in with VS2010). It asks for Username and password which I don't know. What should I do?

I have searched on Google and here too, but nothing of my use.



Thanks in advance.

推荐答案

您可以使用
SetDatabaseLogon







这里的参考链接:

http://msdn.microsoft.com/en-us/library/ ms226061(v = vs.80).aspx [ ^ ]



它是这样的:



dim rpt as new rptCrystalReportFileName



rpt.SetDatabaseLogon(用户名,密码)



希望有帮助...
you can initialize the login authentication by using the
SetDatabaseLogon



here's reference link:
http://msdn.microsoft.com/en-us/library/ms226061(v=vs.80).aspx[^]

its something like this:

dim rpt as new rptCrystalReportFileName

rpt.SetDatabaseLogon(username,password)

hope that helps...


Crystal Report是不同的应用程序,您的数据库(sql express)是不同的应用程序。 Crystal报告依赖于SqlServer来获取数据。当它需要数据时,它会转到sqlserver。然后sqlserver询问您当前面临的身份验证。现在我希望你理解水晶报告实际上要求sqlserver认证信息,它通过它向sqlserver请求数据,并在获得该数据之后,它将在其报告中显示报告查看器组件。以下代码可以帮助您解决水晶报告如何为特定报告配置sqlserver身份验证信息:

Crystal Report is different application, Your database(sql express) is different application. Crystal report depends on SqlServer for data. When it need data then it goes to sqlserver. Then sqlserver ask authentication that you currently face. Now i hope you understand crystal report actually ask sqlserver authentication information by which it request to sqlserver for data and after getting that data it will show that on its report withing report viewer component. The following code can help you which will demonastrate how crystal report configure sqlserver authentication information for a particular report:
void Form_Load(object sender, EventArgs e)
{
       ConnectionInfo myConnectionInfo = new ConnectionInfo();

        myConnectionInfo.ServerName = "serverName";
        myConnectionInfo.DatabaseName = "DatabaseName";
        myConnectionInfo.UserID = "sa";
        myConnectionInfo.Password = "pwd";
        setDBLOGONforREPORT(myConnectionInfo);
}
void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
        TableLogOnInfos mytableloginfos = new TableLogOnInfos();
        mytableloginfos = CrystalReportViewer1.LogOnInfo;
        foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
        {
            myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
        }
 }


尝试打开字段资源管理器--->数据库字段--->右键单击 - >当前数据源--->报告连接----->报告----->属性---->设置属性为---



数据来源:.\Databasename.accdb



和代码观众形式加载为



Dim cryRpt As New ReportDocument



Dim Report1 As new rptItemWise



Dim strServerName As String

strServerName = Application.StartupPath

rptItemWise.SetDatabaseLogon(admin,,strServerName, dastabasename.accdb,真实的)







cryRpt.Load(Application.StartupPath +\\ \\ rptItemWise.rpt)



也会更改与数据源相同的报表连接我认为该代码适合您....
try that open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

Data Source: .\Databasename.accdb

and code on viewer form load as

Dim cryRpt As New ReportDocument

Dim Report1 As New rptItemWise

Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)



cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

also change the report connection same as data source i think that code work for you ....


这篇关于VS2010 Crystal报告要求输入用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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