如何删除Crystal Report上的数据库登录... VB.NET帮助请! [英] How can I remove the Database Login on Crystal Report... VB.NET Help Pls!

查看:60
本文介绍了如何删除Crystal Report上的数据库登录... VB.NET帮助请!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行项目并查找Crystal Report Viewer时,在加载报告之前会提示登录表单。它是一个数据库登录形式......我从未设置过。我该如何删除它?



我使用VB.NET 2010



我在按钮



When I run my project and look for the Crystal Report Viewer a Log in form was prompt before it loads the report. It is a database log in form... which i never set up. how can i remove it??

I use VB.NET 2010

I code this on a button

Dim sqlQuery As String = "SELECT * FROM security_log where Middle_Name= '" & TextBox1.Text & "'"
Dim sqlAdapter As New MySqlDataAdapter
Dim sqlcommand As New MySqlCommand
Dim ds As New DataSet
Dim cryRpt As New ReportDocument
       
Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDoc = New CrystalReport3
Form6.CrystalReportViewer1.ReportSource = rptDoc

With sqlcommand
   .CommandText = sqlQuery
   .Connection = sqlcon
End With

With sqlAdapter
   .SelectCommand = sqlcommand
   .Fill(ds, "security_log")
End With

ds.WriteXml("D:\secl.xml", XmlWriteMode.WriteSchema)
Form6.Show()





form6是Crystal Report查看器的位置..



请帮助



The form6 is where the Crystal Report viewer is..

Please help

推荐答案

您好,如果Crystal Report向您发送登录表单,因为他没有找到数据库凭据



尝试这个





Hi if Crystal Report Send you the login form it's because he doesn't found the database credentials

TRY THIS


Private Sub AssignConnection(rpt As ReportDocument)
    Dim connection As New ConnectionInfo()


     connection.DatabaseName = "YourDataBaseName" 'myDataBase
    connection.ServerName = "YourServerAdress" '127.0.0.1
    connection.UserID = "UserID" 'root
    connection.Password = "Password" '12345



    ' First we assign the connection to all tables in the main report
    '
    For Each table As CrystalDecisions.CrystalReports.Engine.Table In rpt.Database.Tables
        AssignTableConnection(table, connection)
    Next

    ' Now loop through all the sections and its objects to do the same for the subreports
    '
    For Each section As CrystalDecisions.CrystalReports.Engine.Section In rpt.ReportDefinition.Sections
        ' In each section we need to loop through all the reporting objects
        For Each reportObject As CrystalDecisions.CrystalReports.Engine.ReportObject In section.ReportObjects
            If reportObject.Kind = ReportObjectKind.SubreportObject Then
                Dim subReport As SubreportObject = DirectCast(reportObject, SubreportObject)
                Dim subDocument As ReportDocument = subReport.OpenSubreport(subReport.SubreportName)

                For Each table As CrystalDecisions.CrystalReports.Engine.Table In subDocument.Database.Tables
                    AssignTableConnection(table, connection)
                Next

                subDocument.SetDatabaseLogon(connection.UserID, connection.Password, connection.ServerName, connection.DatabaseName)
            End If
        Next
    Next
    rpt.SetDatabaseLogon(connection.UserID, connection.Password, connection.ServerName, connection.DatabaseName)
End Sub


Private Sub AssignTableConnection(ByVal table As CrystalDecisions.CrystalReports.Engine.Table, ByVal connection As ConnectionInfo)
    ' Cache the logon info block
    Dim logOnInfo As TableLogOnInfo = table.LogOnInfo

    connection.Type = logOnInfo.ConnectionInfo.Type

    ' Set the connection
    logOnInfo.ConnectionInfo = connection

    ' Apply the connection to the table!

    table.LogOnInfo.ConnectionInfo.DatabaseName = connection.DatabaseName
    table.LogOnInfo.ConnectionInfo.ServerName = connection.ServerName
    table.LogOnInfo.ConnectionInfo.UserID = connection.UserID
    table.LogOnInfo.ConnectionInfo.Password = connection.Password
    table.LogOnInfo.ConnectionInfo.Type = connection.Type
    table.ApplyLogOnInfo(logOnInfo)
End Sub


这篇关于如何删除Crystal Report上的数据库登录... VB.NET帮助请!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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