如何使用 VB.NET 检测 Crystal Reports 中的可信连接?

发布于 2024-08-27 01:20:15 字数 551 浏览 3 评论 0原文

我有一些连接到 Sql Server 数据库的 Crystal Reports,我想检测连接是否受信任或者是否需要提供登录信息(报告不是由我提供,因此我无法控制连接方法)。如果我只是盲目地提供登录凭据,如果它是受信任的连接,它就不会连接。

以下不起作用:

oRpt = oCR.OpenReport("C:\MyReport.rpt")

if oRpt.Database.Tables(1).ConnectionProperties.Item("Integrated Security") = True then 
       'trusted connection
    else
       'supply login credentials
    end if

它给出以下错误: 未为类型“IConnectionProperty”和类型“Boolean”定义运算符“=”。

我找不到如何在 vb.net 中为 IConnectionProperty 创建构造。我在 Crystal 中找不到任何解释它的文档。 我正在使用 Crystal Reports XI - 开发人员

I have some Crystal Reports connecting to a Sql Server db that I would like to detect whether the connection is trusted or whether I need to supply the log on info (reports are not supplied by me so I can't control the connect method). If I just blindly supply login credentials, it won't connect if it is a trusted connection.

The following does not work:

oRpt = oCR.OpenReport("C:\MyReport.rpt")

if oRpt.Database.Tables(1).ConnectionProperties.Item("Integrated Security") = True then 
       'trusted connection
    else
       'supply login credentials
    end if

It gives the following error:
Operator '=' is not defined for type 'IConnectionProperty' and type 'Boolean'.

I cannot find how create a construct in vb.net for IConnectionProperty. I can't find any documents from Crystal that explain it.
I am using Crystal Reports XI - Developer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

找回味觉 2024-09-03 01:20:15

我想我找到了答案。通过使用 ConnectBufferString 属性,

如下所示:

Console.WriteLine(oRpt.Database.Tables(1).ConnectBufferString.ToString)

它将为您提供一个类似这样的字符串

Provider=SQLOLEDB;;Data Source=MYPC\SQLEXPRESS;;Initial Catalog=sample_db;;User ID=;;Password=;;Integrated Security=-1; ;使用 DSN 默认属性=0;;区域设置标识符=1033;;连接超时=15;;常规超时=0;;OLE DB 服务=-5;;当前语言=;;初始文件名=;;对数据使用加密=0;;复制服务器名称连接选项=;;可能时使用列排序规则标记=0

您只需查找以下内容:

集成安全性=-1 = 可信连接

集成安全性=0 = 不可信连接

希望这对其他人有帮助,因为我浪费了几个小时的寻找。

I think i found the answer. By using the property ConnectBufferString

Like this:

Console.WriteLine(oRpt.Database.Tables(1).ConnectBufferString.ToString)

It will give you a string like this

Provider=SQLOLEDB;;Data Source=MYPC\SQLEXPRESS;;Initial Catalog=sample_db;;User ID=;;Password=;;Integrated Security=-1;;Use DSN Default Properties=0;;Locale Identifier=1033;;Connect Timeout=15;;General Timeout=0;;OLE DB Services=-5;;Current Language=;;Initial File Name=;;Use Encryption for Data=0;;Replication server name connect option=;;Tag with column collation when possible=0

You just look for the following:

Integrated Security=-1 = Trusted Connection

Integrated Security=0 = Untrusted Connection

Hope this helps someone else since I wasted a few hours looking.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文