Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: how to fetch the single row from data base Post Reply Post New Topic
Author Message
Ankit89
Newbie
Newbie


Joined: 24 Apr 2012
Location: India
Online Status: Offline
Posts: 2
Quote Ankit89 Replybullet Topic: how to fetch the single row from data base
    Posted: 24 Apr 2012 at 12:17pm
 In crystal report :
"plz help me "to select only one particular row "

my default.aspx file :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body background="images/bg.jpg" >
   
   
    <form id="form1" runat="server">
   
   <img src="images/cm.png" height="100" style="height: 100px"/> 
    <p align="center">
    <img src="images/ms2.png" height="50" width="50">Missing Person ID
    
        <asp:DropDownList ID="DropDownList1" runat="server"
            DataSourceID="SqlDataSource1" DataTextField="MP_ID" DataValueField="MP_ID">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:crmConnectionString %>"
           
            SelectCommand="SELECT [MP_ID], [DOB], [Address], [Complexion], [Height], [Gender] FROM [Missing_Person]"></asp:SqlDataSource>
    
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </p>
    <p align="center">  
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
       
</form>
     
</body>
</html>

my Default.aspx.cs file
:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
//Import These two namespaces
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["crmConnectionString"].ConnectionString);
        con.Open();
        string sql1 = "select MP_ID, DOB , Height , Address , Complexion , Gender from Missing_Person where  (MP_ID = 3 AND First_Name='Ravi') ";
        SqlDataAdapter da = new SqlDataAdapter(sql1,con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        ReportDocument rep_doc = new ReportDocument();
        rep_doc.Load(Server.MapPath("~/FirReport.rpt"));
        rep_doc.SetDataSource(ds.Tables[0]);
        CrystalReportViewer1.ReportSource = rep_doc;
        //Following Statements are Optional
        CrystalReportViewer1.DataBind();
        CrystalReportViewer1.RefreshReport();
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
   
}
\\"string sql1 = "select MP_ID, DOB , Height , Address , Complexion , Gender from Missing_Person where  (MP_ID = 3 AND First_Name='Ravi') ";
"in this query when i try to fetch only 1 row through MP_ID and First_name
and execute in browser MissingPerson-1(drop down list)
"the result in browser shows whole rows data of all the pages

"plz help me "to select only one particular row " like
if i choose MP_ID 1 - only Missing person id 1 data(row)  comes into the browser. Confused
Ankit
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.