如何使用 VB.NET 检测 Crystal Reports 中的可信连接?
我有一些连接到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了答案。通过使用 ConnectBufferString 属性,
如下所示:
它将为您提供一个类似这样的字符串
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:
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.