Sir,
Here is .vb file
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Partial Class Default2
Inherits System.Web.UI.Page
Public sqlfile As String
Dim payslip As New ReportDocument()
Protected Sub TXTNAME_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TXTNAME.TextChanged
sqlfile = "pay" + Mid(cboyear.Text, 3, 2) + cbomonth.Text
SQLPAY.SelectCommand = "SELECT [NAME], [SECTION], [DESIGNAT], [BASIC], [SPL_PAY], [DA], [HRA], [EMPNO] FROM " & sqlfile & " WHERE ([NAME] LIKE '%' + @NAME + '%')"
GridView1.Visible = True
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' If Not IsPostBack Then
Dim crystalReport As New ReportDocument()
crystalReport.Load(Server.MapPath("~/payslip.rpt"))
Dim dspay As Paydata = GetData("select * from " & sqlfile & " where empno=" & GridView1.SelectedDataKey.Value & "")
crystalReport.SetDataSource(dspay)
crpayslip.ReportSource = crpayslip
'End If\
End Sub
Private Function GetData(ByVal query As String) As Paydata
Dim conString As String = ConfigurationManager.ConnectionStrings("payrollConnectionString").ConnectionString
Dim cmd As New SqlCommand(query)
Using con As New SqlConnection(conString)
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dsCustomers As New Paydata()
sda.Fill(dsCustomers, "paysliptable")
Return dsCustomers
End Using
End Using
End Using
End Function
End Class
Here is web.config
<?xml version="1.0"?><!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
--><configuration>
<configSections>
<sectionGroup name="businessObjects">
<sectionGroup name="crystalReports">
<section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null"/>
<section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true"/>
<add key="CrystalImageCleaner-Sleep" value="60000"/>
<add key="CrystalImageCleaner-Age" value="120000"/>
</appSettings>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="ConnectionStringpay" connectionString="Data Source=win7\SQLEXPRESS;Persist Security Info=True;User ID=sa;Password=saadmin" providerName="System.Data.SqlClient"/>
<add name="payrollConnectionString" connectionString="Data Source=acclap\SQLEXPRESS;Initial Catalog=payroll;Persist Security Info=True;User ID=sa;Password=saadmin" providerName="System.Data.SqlClient"/>
<add name="accountsConnectionString" connectionString="Data Source=acclap\SQLEXPRESS;Initial Catalog=accounts;User ID=sa;Password=saadmin; MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/>
<add name="genere" connectionString="Data Source=WIN7\SQLEXPRESS;Initial Catalog=accounts;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="incexpConnectionString" connectionString="ProviderName=Microsoft.Jet.OLEDB.4.0;Data Source=D:\modata\incexp.mdb;Persist Security Info=True;Jet OLEDB:Database Password=seeanu"/>
<add name="examiner" connectionString="Data Source=acclap\sqlexpress;Initial Catalog=examiner;Persist Security Info=True;User ID=sa;Password=saadmin" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="CrystalDecisions.CrystalReports.Design, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/></assemblies><buildProviders><add extension=".rpt" type="CrystalDecisions.Web.Compilation.RptBuildProvider, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></buildProviders></compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear/>
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
</providers>
</roleManager>
<httpHandlers><add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"/></system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers><!-- <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" /> -->
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/></handlers>
<validation validateIntegratedModeConfiguration="false"/>
<security>
<authentication>
<anonymousAuthentication enabled="true" userName=""/>
</authentication>
</security></system.webServer>
<businessObjects>
<crystalReports>
<rptBuildProvider>
<add embedRptInResource="true"/>
</rptBuildProvider>
<crystalReportViewer>
<add key="ResourceUri" value="/crystalreportviewers13"/>
</crystalReportViewer>
</crystalReports>
</businessObjects>
</configuration>