این کد منه .
amespace Crsytal_Query
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string databaseAddress = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0}\db1.accdb", Environment.CurrentDirectory);
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// id,zarfiyatSUM(zarfiyat),,gheymat,shomareparvande
string strq = String.Format("select id,sum(zarfiyat),gheymat,shomareparvande from table2 where id=2"
+" group by id,gheymat,shomareparvande "); //GROUP BY id");
// string strq = String.Format("select id,zarfiyat,gheymat,shomareparvande from table2 where id=2 "); //GROUP BY id");
DataSet DS1 = new DataSet();
DS1.Clear();
OleDbConnection con = new OleDbConnection();
OleDbDataAdapter da = new OleDbDataAdapter();
con.ConnectionString = databaseAddress;
da.SelectCommand = new OleDbCommand();
da.SelectCommand.Connection = con;
da.SelectCommand.CommandText = strq;
da.SelectCommand.CommandType = CommandType.Text;
da.Fill(DS1, "Tbl1");
con.Close();
CrystalReport1 cr1 = new CrystalReport1();
cr1.SetDataSource(DS1.Tables["Tbl1"]);
crystalReportViewer1.ReportSource = cr1;
}
}
}
جواب من این شکلی تو کریستال میاد مثلا:
id اینجا باید sum zarfiyat باشه که نیست shomareparvande gheymat
2 خالی 100 20
2 خالی 200 40
----------------------------------------------------------------------------------------------------------------------------
این بالا خروجی من بود اما موضوع اینه که من باید اینو طوری طراحی کنم که که تو ظرفیت sum رو داشته باشم. من نمیدونم چقدر این کاری که کردم درست باشه . لطفا" برنامه ای رو که up کردم رو بردارین و روش کار کنین ببینین که طوری میشه ازش جواب گرفت خودمم موندم چه شکلب اینو کار کنم. لطفا" هر طوری که میشه کمک کنبن منو. در شمن دوسمونم سه کد بالا نوشت اما نمیدونم تا چه جوری بتونم ازش استفاده کنم . لطفا کمک کنین .