using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;



namespace test
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        string username;
        string fname;

        protected void submit_Click(object sender, EventArgs e)
        {
            username = nametxtbox.Text;
            fname = fnametxtbox.Text;

            CrystalReport1 report = new CrystalReport1();

            using (SqlConnection con = DALHelper.GetConnection())
            {

                SqlCommand cmd = new SqlCommand("testsproc", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@username",username);
                cmd.Parameters.AddWithValue("@fname", fname);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet1 ds = new DataSet1();
                da.Fill(ds, "users");

                CrystalReportViewer1.Visible = true;

                report.SetDataSource(ds.Tables["users"]);

                CrystalReportViewer1.ReportSource = report;
                CrystalReportViewer1.RefreshReport();


                try
                {
                    con.Open();
                    int count = cmd.ExecuteNonQuery();

                }
                catch
                {
                    throw;

                }

                finally
                {
                    if (con != null)
                    {
                        con.Close();
                        con.Dispose();

                    }
                    cmd.Dispose();
                }


            }
        }
    }
}




************Webform*********

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test.WebForm1" %>

<%@ 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>
    Name    <asp:TextBox id="nametxtbox" runat="server"></asp:TextBox>
    <br />
    <br />
    Father Name    <asp:TextBox id="fnametxtbox" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="submit" runat="server" Text="Submit" onclick="submit_Click" />
    </div>
    </form>
    <div>

        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            AutoDataBind="false" Height="1039px" ReportSourceID="CrystalReportSource1" 
            Width="901px"  />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report FileName="CrystalReport1.rpt">
            </Report>
        </CR:CrystalReportSource>    
    </div>
</body>
</html>

*********** Please help its my job requirement and i am unable to sort out problem plz plz************
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.