Hi,

Dear Friends im new with Crystal Report, i have created the crystal report by using the step by step procedure from the following link:

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-stepbystep.htm

Now When i run it it always asking me the username and Password, i am using MS ACCESS Database, and i didn't set any username or Password,

Now what should i do....????:(

Post your code... Be sure to enclose in code tags.

Here is the Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;


using CrystalDecisions.Shared; 

namespace khalid_pipes
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load("D:\\PROJECTS\\Khalid Pipes\\coding\\khalid_pipes\\khalid_pipes\\CrystalReport1.rpt");
            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh();
            



          

        }
    }
}

I have not used a CrystalReportViewer control. I did try to replicate your issue with my project and database, but all I got was an empty view when I mimicked your code--no error, but no data either.

Can you zip up the project (include database)?

Try this:

crystalReportViewer1.LogOnInfo[0].ConnectionInfo.IntegratedSecurity = true;

Insert this line after you've set the ReportSource property.

I also had the same problem. This is how i solved my problem. Try this.

ReportDocument cryRpt = new ReportDocument();
cryRpt .DataSourceConnections[0].SetConnection(Path, "", false);
crystalReportViewer1.ReportSource = cryRpt;

where Path - is the path of your database.
false - if you are not using IntegratedSecurity or true if you are
using IntegratedSecurity.

Dear Friend i when i enter the following

"Object reference is not set to an instance of an Object"

i have also attached the Picture of Error...

Dear hemaljoes

I used ur given code, but when i enter the Database path, it gives me error that "Invalid Report Path"

and if i give the Correct report path its also gives me the same error...

Dear Friend i have also attached the snap of my IDE with Error...

Please anybody solve the problem...?? :(

Try typing the IntegratedSecurity line after you have specified the ReportSource.

Try typing the IntegratedSecurity line after you have specified the ReportSource.

Dear "jatin24"

I have typed the IntegratedSecurity line after the ReportSource, now again it asking me for the login info :(

here is the Code (I also attached the snap of my software window)

CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.OleDb;

using CrystalDecisions.Shared; 

namespace khalid_pipes
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load("D:\\PROJECTS\\Khalid Pipes\\coding\\khalid_pipes\\khalid_pipes\\CrystalReport1.rpt");
            
            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.LogOnInfo[0].ConnectionInfo.IntegratedSecurity = true;

        }
    }
}

Thanx Dear Friends the problem is Solved... :)

u people are very very very hardworking and Friendly... Thanx Alot my Dear Dear Dearest Friends...

I went through the steps on how you created the crystal report.

In selecting the OLE DB Provider it had selected

OLE DB Provider for SQL Server

But you have said that you used MS Access as your database.
I think the DB Provider should be

Microsoft Jet 4.0 OLE DB Provider.

Try to create a connection using that connection.
When you select that option You will get dialog box like in the snapshot.
there in the database name click the button and select your database.

and do the next steps as it is describe in that web page.
It should work.

Thanx Dear Friends the problem is Solved... :)

Hi,

I am facing the same database login error that u were facing some time back, please let me know how you resolved the error.i will appereciate ur help. Looking for a response. Thanks in anticipation.

Circuit

Hi,

I am also having the same issue with the login. But I've used a dataset within my project instead of reading data from an external database. I've tried all suggested above but nothing seems to work. Can someone share with me know this problem was resolved.
Thank you.

   Dim myConnection As System.Data.OleDb.OleDbConnection = _
        New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & _
                                              FileLocation & "';Extended Properties=Excel 8.0;")

  Private Sub btnSelect_Click(sender As System.Object, e As System.EventArgs) Handles btnSelect.Click
        Dim btnCommand As System.Data.OleDb.OleDbDataAdapter
        Dim cryRpt As New ReportDocument
        Dim rptLocation As String

        'File location.  Environment directory path used.
        rptLocation = Environment.CurrentDirectory & "\pltpaper.rpt"
        'MsgBox(rptLocation)

        btnCommand = New System.Data.OleDb.OleDbDataAdapter("SELECT Index, Model, Control, Serial, PLT FROM [ScanData$] WHERE PLT = '" & cbPallet.SelectedValue & "'", myConnection)

        Try
            GoodDataSet1.GoodTable.Clear()
            btnCommand.Fill(GoodDataSet1.GoodTable)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Try
            cryRpt.Load(rptLocation)


            CrystalReportViewer1.ReportSource = cryRpt
            CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.IntegratedSecurity = True

            'cryRpt.DataSourceConnections(0).SetConnection(Environment.CurrentDirectory, "", False)
            CrystalReportViewer1.Refresh()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

eassy and simple solution for all ....
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 ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.