Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Am new to programming, i build an application for a store in visual studio using c# and crystal report for report generation. but i have a problem with the report, i have a query that i use to fetch data from my sql database and display it on my crystal report but the data field are not showing on the crystal report.

What I have tried:

C#
public DataSet Getindividualsales(string date1, string date2)
        {
            DataSet ds = new DataSet();
            string sql = "select Customer_id, Fullname,  Description, SUM (TotAmnt) AS TotAmnt from Summary  where Date between'" + Convert.ToDateTime(date1) + "' and '" + Convert.ToDateTime(date2) + "'GROUP BY Customer_id";
            SqlDataAdapter dadbt = new SqlDataAdapter(sql, mycon.Opencon());
            dadbt.Fill(ds);
            dadbt.Dispose();
            return ds;
        }
Posted
Updated 11-Jun-16 3:07am
v2
Comments
CHill60 11-Jun-16 9:09am    
When you debug is there any data in the Dataset?
Your code is also vulnerable to SQL Injection - never concatenate strings to create SQL queries
George Jonsson 11-Jun-16 11:02am    
How do you call this method?
Can you show that piece of code?

Also, why not use DateTime as parameters?
public DataSet Getindividualsales(DateTime date1, DateTime date2)
makes your method neater.
Member 12414126 11-Jun-16 12:59pm    
Here is the error code that i get
Column 'Summary.Fullname' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900