Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: obtain web service results Pin
Pete O'Hanlon1-Sep-12 23:19
mvePete O'Hanlon1-Sep-12 23:19 
AnswerRe: obtain web service results Pin
PIEBALDconsult2-Sep-12 5:44
mvePIEBALDconsult2-Sep-12 5:44 
GeneralRe: obtain web service results Pin
dcof2-Sep-12 11:49
dcof2-Sep-12 11:49 
AnswerRe: obtain web service results Pin
jschell2-Sep-12 7:38
jschell2-Sep-12 7:38 
GeneralRe: obtain web service results Pin
dcof2-Sep-12 12:02
dcof2-Sep-12 12:02 
GeneralRe: obtain web service results Pin
PIEBALDconsult2-Sep-12 12:52
mvePIEBALDconsult2-Sep-12 12:52 
GeneralRe: obtain web service results Pin
jschell4-Sep-12 11:08
jschell4-Sep-12 11:08 
GeneralRe: obtain web service results Pin
Member 26898653-Sep-12 21:32
Member 26898653-Sep-12 21:32 
AnswerRe: obtain web service results Pin
BillWoodruff3-Sep-12 15:04
professionalBillWoodruff3-Sep-12 15:04 
QuestionC#: solved Pin
Hbr_Tha_real1-Sep-12 11:53
Hbr_Tha_real1-Sep-12 11:53 
AnswerRe: C# PinPopular
AspDotNetDev1-Sep-12 15:17
protectorAspDotNetDev1-Sep-12 15:17 
GeneralRe: C# Pin
Hbr_Tha_real1-Sep-12 21:25
Hbr_Tha_real1-Sep-12 21:25 
AnswerRe: C# Pin
Dave Kreskowiak1-Sep-12 18:47
mveDave Kreskowiak1-Sep-12 18:47 
GeneralRe: C# Pin
Member 26898653-Sep-12 21:33
Member 26898653-Sep-12 21:33 
GeneralRe: C# Pin
Member 26898653-Sep-12 21:34
Member 26898653-Sep-12 21:34 
GeneralRe: C# Pin
Pete O'Hanlon3-Sep-12 22:20
mvePete O'Hanlon3-Sep-12 22:20 
GeneralRe: C# Pin
Dave Kreskowiak4-Sep-12 2:08
mveDave Kreskowiak4-Sep-12 2:08 
QuestionSet a Value to Crystal Report Field using C# Pin
lesponce1-Sep-12 8:25
lesponce1-Sep-12 8: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 13:59
professionalMycroft Holmes1-Sep-12 13:59 
GeneralRe: Set a Value to Crystal Report Field using C# Pin
lesponce1-Sep-12 18:58
lesponce1-Sep-12 18:58 
QuestionC# application obtain results of program it executes Pin
dcof1-Sep-12 7:43
dcof1-Sep-12 7:43 
AnswerRe: C# application obtain results of program it executes Pin
Shameel1-Sep-12 8:23
professionalShameel1-Sep-12 8:23 
AnswerRe: C# application obtain results of program it executes Pin
dbaseman1-Sep-12 10:21
dbaseman1-Sep-12 10:21 
GeneralRe: C# application obtain results of program it executes Pin
jschell1-Sep-12 11:28
jschell1-Sep-12 11:28 
GeneralRe: C# application obtain results of program it executes Pin
dbaseman1-Sep-12 17:37
dbaseman1-Sep-12 17:37 

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.