**********************************please see the image first link given below*********************************

I have made a crystal report to assign a database to it i created a module with following code and added this module to my form

Imports System.Data.SqlClient
Imports System.Data.Sql

Module Module1
    Public acscmd As New SqlCommand
    Public acsconn As New SqlConnection
    Public acsda As New SqlDataAdapter
    Public acsds As New DataSet
    Public strsql As String
    Public Strreportname As String
    Sub Connect()
        acsconn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Items.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;"
        acsconn.Open()
        If acsconn.State = ConnectionState.Open Then
            MsgBox("Connected")
        End If
    End Sub

End Module

and in form 2 i dropped a crystal report viewer and crystal report document for that i write this code and a print button

Imports CrystalDecisions.CrystalReports.Engine


Public Class Form2


    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        strsql = "select * from Items"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)
        Strreportname = "CrystalReport1"
        Dim Strreportpath As String = Application.StartupPath & "\" & Strreportname & ".rpt"
        If Not IO.File.Exists(Strreportpath) Then
            Throw (New Exception("Unable to load report charu"))

        End If

        Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        rptdocument.Load(Strreportpath)
        rptdocument.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ShowRefreshButton = False
        CrystalReportViewer1.ShowCloseButton = False
        CrystalReportViewer1.ShowGroupTreeButton = False
        CrystalReportViewer1.ReportSource = rptdocument

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        cryRpt.Load("C:\Users\Dell\Desktop\WindowsApplication3\WindowsApplication3\CrystalReport1.rpt")
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.RefreshReport()
    End Sub
End Class

when compiling no error see this image i dont know how to fill up these details please help me how to fill up these connection details.image details

see image :
please give which details to be filled and how can i determine them

please please help me

Dani AI

Generated

Two practical ways to fix the Crystal Reports logon/connection dialog you’re seeing (and which hinted at). Either remove the report’s built‑in DB connection and use a typed ADO.NET DataSet (recommended), or keep the report bound to SQL Server and programmatically supply explicit logon info for every report table and subreport.

If you take the “push” approach (recommended): create a strongly‑typed DataSet (.xsd) that matches your Items table, design the .rpt against that DataSet (Project Data → ADO.NET DataSets), and at run time fill that DataSet and give it to the report. Because the report is bound to the schema rather than a live server, Crystal won’t prompt for connection details and deployment is simpler.

If you must use the “pull” approach (report queries DB directly), you need to set ConnectionInfo for every table the report uses and also for each subreport. Example VB.NET pattern to apply a single ConnectionInfo to the main report tables (apply the same logic to any subreports you open):

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Sub ApplyLogonInfo(reportDoc As ReportDocument, server As String, database As String, useIntegrated As Boolean, Optional uid As String = "", Optional pwd As String = "")
    Dim ci As New ConnectionInfo()
    ci.ServerName = server
    ci.DatabaseName = database
    ci.IntegratedSecurity = useIntegrated
    If Not useIntegrated Then
        ci.UserID = uid
        ci.Password = pwd
    End If

    For Each t As Table In reportDoc.Database.Tables
        Dim tli As TableLogOnInfo = t.LogOnInfo
        tli.ConnectionInfo = ci
        t.ApplyLogOnInfo(tli)
    Next

    ' For subreports: open each subreport and repeat the same table loop using reportDoc.OpenSubreport(name)
End Sub

Troubleshooting notes: ensure the SQL Express instance is running and the DB is either attached to the instance (preferred) or reachable with the same connection format Crystal expects; designer tools sometimes don’t accept an AttachDbFilename/user‑instance path, so attaching the MDF with SQL Server Management Studio and using the DB name usually helps. Also check Crystal runtime vs. app bitness (set Platform Target to x86 if using the common 32‑bit CR runtime) and make sure any subreports get the same logon treatment.

I believe you need to provide a the connection and logon properties separately for Crystal Reports. I haven't had a chance to look into it yet, but have seen that mentioned in other discussions. You might try the Crystal Reports SDK , and look through their discussion groups to see if there's a quick answer applicable to your situation. Their community landing page for Visual Studio is here.

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.