Click here to Skip to main content
15,569,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Pin
AspDotNetDev1-Sep-12 16:17
protectorAspDotNetDev1-Sep-12 16:17 
GeneralRe: C# Pin
Hbr_Tha_real1-Sep-12 22:25
Hbr_Tha_real1-Sep-12 22:25 
AnswerRe: C# Pin
Dave Kreskowiak1-Sep-12 19:47
mveDave Kreskowiak1-Sep-12 19:47 
GeneralRe: C# Pin
Member 26898653-Sep-12 22:33
Member 26898653-Sep-12 22:33 
GeneralRe: C# Pin
Member 26898653-Sep-12 22:34
Member 26898653-Sep-12 22:34 
GeneralRe: C# Pin
Pete O'Hanlon3-Sep-12 23:20
mvaPete O'Hanlon3-Sep-12 23:20 
GeneralRe: C# Pin
Dave Kreskowiak4-Sep-12 3:08
mveDave Kreskowiak4-Sep-12 3:08 
QuestionSet a Value to Crystal Report Field using C# Pin
lesponce1-Sep-12 9:25
lesponce1-Sep-12 9:25 
CSS
I need to know  how to map fields coming from a stored procedure to  output fields on a crystal report.  Any feedback is greatly appreciated.  The output that I'm getting on the report is the name of the fields instead of the values coming from the database.

Also, If at least someonce can tell me how to assign the database value on the .xsd Default Value, that'd help.  Right now if I type "TEST" on the .xsd Default Value property (hardcoded), it gets displayed on the report. I need to be able to set that value with the one coming from my database. 

The code is based on this sample:

http://www.codeproject.com/Articles/166291/Generate-a-report-using-Crystal-Reports-in-Visual

Here's my code:


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

namespace project
{
public partial class check : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument rptCheck = new ReportDocument();
dsCheck ds = new dsCheck(); // .xsd file name
DataTable dt = new DataTable();


// Just set the name of data table
dt.TableName = "Crystal Report Checks";
dt = getChecks(); //This function is located below this function
ds.Tables[0].Merge(dt);

// Your .rpt file path will be below
rptCheck.Load(Server.MapPath("checkprt.rpt"));

//set dataset to the report viewer.
CrystalReportViewer1.ReportSource = rptCheck;


}


public DataTable getChecks()
{
string sqlCon = WebConfigurationManager.ConnectionStrings["hello"].ConnectionString;
SqlConnection Con = new SqlConnection(sqlCon);
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
try
{
Con.Open();
//Stored procedure calling. It is already in sample db.
cmd.CommandText = "spGetData";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Date", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Amount", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@AccountID", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

cmd.Connection = Con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);

//get output param list
string Count1 = cmd.Parameters["@Date"].Value.ToString();
string Count2 = cmd.Parameters["@Name"].Value.ToString();

}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
if (Con.State != ConnectionState.Closed)
Con.Close();
}
return ds.Tables[0];
}


}
}
AnswerRe: Set a Value to Crystal Report Field using C# Pin
Mycroft Holmes1-Sep-12 14:59
professionalMycroft Holmes1-Sep-12 14:59 
GeneralRe: Set a Value to Crystal Report Field using C# Pin
lesponce1-Sep-12 19:58
lesponce1-Sep-12 19:58 
QuestionC# application obtain results of program it executes Pin
dcof1-Sep-12 8:43
dcof1-Sep-12 8:43 
AnswerRe: C# application obtain results of program it executes Pin
Shameel1-Sep-12 9:23
professionalShameel1-Sep-12 9:23 
AnswerRe: C# application obtain results of program it executes Pin
dbaseman1-Sep-12 11:21
dbaseman1-Sep-12 11:21 
GeneralRe: C# application obtain results of program it executes Pin
jschell1-Sep-12 12:28
jschell1-Sep-12 12:28 
GeneralRe: C# application obtain results of program it executes Pin
dbaseman1-Sep-12 18:37
dbaseman1-Sep-12 18:37 
GeneralRe: C# application obtain results of program it executes Pin
jschell2-Sep-12 8:20
jschell2-Sep-12 8:20 
AnswerRe: C# application obtain results of program it executes Pin
Mycroft Holmes1-Sep-12 14:54
professionalMycroft Holmes1-Sep-12 14:54 
QuestionC# obtain results of program it calls Pin
dcof1-Sep-12 8:41
dcof1-Sep-12 8:41 
AnswerRe: C# obtain results of program it calls Pin
AmitGajjar1-Sep-12 17:19
professionalAmitGajjar1-Sep-12 17:19 
AnswerRe: C# obtain results of program it calls Pin
BobJanova3-Sep-12 2:36
BobJanova3-Sep-12 2:36 
QuestionC# console log file Pin
dcof1-Sep-12 8:07
dcof1-Sep-12 8:07 
AnswerRe: C# console log file Pin
Dr.Walt Fair, PE1-Sep-12 8:39
professionalDr.Walt Fair, PE1-Sep-12 8:39 
AnswerRe: C# console log file Pin
AmitGajjar1-Sep-12 17:27
professionalAmitGajjar1-Sep-12 17:27 
AnswerRe: C# console log file Pin
PIEBALDconsult1-Sep-12 18:44
professionalPIEBALDconsult1-Sep-12 18:44 
QuestionC# 2008 dynamic path Pin
sc steinhayse1-Sep-12 7:36
sc steinhayse1-Sep-12 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.