Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2006, 03:02 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deepakbachelor
Default Using Crystal Report with SQL SERVER

Hi All I am writing Code for using Crystal Report with App.config.This should be used for Windows Application only.


Imports CrystalDecisions.crystalreports.engine
Imports CrystalDecisions.reportsource
Imports CrystalDecisions.shared
Imports CrystalDecisions.windows.forms

Public Class Form2
    Inherits System.Windows.Forms.Form

  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table
        Dim TableCounter
        Dim crReportDocument1 As New RptBill
        Dim crReportDocument As New ReportDocument
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues
        Dim billno As New InfoGeneration
        Dim sname As Configuration.ConfigurationSettings
        crReportDocument.Load("../RptBill.rpt")
        With crConnectionInfo
            .ServerName = sname.AppSettings("servername")
            .DatabaseName = sname.AppSettings("dbname")
            .UserID = sname.AppSettings("username")
            .Password = sname.AppSettings("password")
        End With
        CrTables = crReportDocument.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next
        CrystalReportViewer1.ReportSource = crReportDocument
        crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields
        crParameterFieldLocation = crParameterFieldDefinitions.Item("@billno")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = billno.intBillNo
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldLocation.ApplyCurrentValues(crPara meterValues)
        CrystalReportViewer1.Show()
    End Sub
End Class

ADD a APP.Config by Right click on Solution Explorer for creating dyanamic connection
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="servername" value="SERVERNAME"></add>
<add key="dbname" value="DATABASENAME"></add>
<add key="username" value="USERNAME "></add>
<add key="password" value="PASSWORD "></add>
</appSettings>
</configuration>


Deepak Kumar Sharma
PGMS Inc(Noida)(India)
Mobile:09313107703





Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report & VB6 & SQL Server wlho VB How-To 2 June 5th, 2013 01:58 AM
how to call sql server function in crystal report arumugavel Access VBA 0 November 16th, 2006 12:05 AM
Connect Seagate Crystal Report with SQL Server 200 abypvarghese SQL Server 2005 6 June 23rd, 2006 03:10 AM
benifit of crystal report with asp and sql server ak SQL Server ASP 9 November 24th, 2005 09:14 PM
SQL Server 2000, ASP and Crystal Report quinn SQL Server ASP 0 March 9th, 2004 02:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.