Skip to Content

SAP Crystal Report using SQL Server Authentication and Windows Authenticati

I'm a SAP Crystal Report, version for Visual Studio 2010 Beginner

my ingredients are

1.windows 7 ultimate service pack1

2.sql server 2008 standard edition

3.visual studio 2010 pro

4.SAP Crystal Report, version for visual studio.net

I was created a report named customersByCity.rpt using OLE DB (ADO) -> Microsoft OLE DB Provider for SQL Server -> I'm supply Server, User ID, Password and Database. I assume me using SQL Server Authentication for my report

Then, my ASP.NET files as following

//ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="viewCustomersByCity.aspx.cs" Inherits="viewCustomersByCity" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div><asp:Label ID="lblMsg" runat="server" BackColor="Yellow" ForeColor="Black"></asp:Label>
 <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"></CR:CrystalReportViewer>
    </div>
    </form>
</body>
</html>


//code-behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class viewCustomersByCity : System.Web.UI.Page
{
    private const string PARAMETER_FIELD_NAME = "city";    
    private ReportDocument customersByCityReport;
    
    private void ConfigureCrystalReports()
    {                
        ConnectionInfo connectionInfo = new ConnectionInfo();
        
        connectionInfo.ServerName = @"WKM1925-PCWKM1925";
        connectionInfo.DatabaseName = "Northwind";
        connectionInfo.UserID = "sa";
        connectionInfo.Password = "sysadmin25";

        SetDBLogonForReport(connectionInfo);
    }

    private void SetDBLogonForReport(ConnectionInfo connectionInfo)
    {
        TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;

        foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
        {
            tableLogOnInfo.ConnectionInfo = connectionInfo;
        }
    }

    private void SetCurrentValuesForParameterField(ReportDocument reportDocument, ArrayList arrayList)
    {
        ParameterValues currentParameterValues = new ParameterValues();
        foreach (object submittedValue in arrayList)
        {
            ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
            parameterDiscreteValue.Value = submittedValue.ToString();
            currentParameterValues.Add(parameterDiscreteValue);
        }

        ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;

        ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_NAME];

        parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {                
        customersByCityReport = new ReportDocument();
        string reportPath = Server.MapPath("customersByCity.rpt");
        customersByCityReport.Load(reportPath);

        ConfigureCrystalReports();

        ArrayList arrayList = new ArrayList();

        arrayList.Add("paris");
        arrayList.Add("Madrid");
        arrayList.Add("Marseille");
        arrayList.Add("Buenos Aires");
        arrayList.Add("Sao Paulo");

        ParameterFields parameterFields = CrystalReportViewer1.ParameterFieldInfo;
        SetCurrentValuesForParameterField(customersByCityReport, arrayList);

        CrystalReportViewer1.ReportSource = customersByCityReport;
    }
}

1st scenario

-

-


When in a runtime, it's keep appear a dialog box. This dialog box ask me to suppy Server, User ID, Password and Database. Once all information is supplied, my report display the data as expected

2nd scenario

-

-


I change my report using OLE DB (ADO) -> Microsoft OLE DB Provider for SQL Server -> checked on Integrated Security. I just choose Server, and Database. I assume me using Windows Authentication

When in a runtime, there's no dialog box as above. My report display the data as expected. really cool

Look's like, when report using SQL Server Authentication there's some problem. but, when report using Windows Authentication, it's fine.

I'm looking for comment. Please help me

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Aug 22, 2011 at 03:18 AM

    Hello,

    MS SQL Server 2008 requires you to install the MS Client Tools for 2008.

    Once install then update all of your reports to use the SQL Native 10 as the OLE DB driver.

    The try again, if it still fails search, lots of sample log on code in this forum.

    Don

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.