PDA

View Full Version : سوال: ارسال کویری دیتاست به استیمیول ریپورت



hamid30sharp
شنبه 06 دی 1393, 16:55 عصر
با سلام
من یک کویری در دیتاستم ایجاد کردم به این شکل
SELECT fid, fname, mother_name, birthday, birthday_place, address, tell1, tell2, eye_test, register_date, driving
FROM [14n]
WHERE (fid = ?)

حالا می خوام نتیجه این جستجو رو به استیمیول بفرستم اما نمی دونم چه طوری بایستی کویری رو فراخوانی کنم و به استیمیول بفرستمو
قبلا با کد نویسی این کار رو کردم اما میخوام بدون کد و با ارسال کویری دیتاست این کار رو انجام بدم.
try
{

cmd.CommandText = "Select * from y14n Where ID=" + Convert.ToInt32(label2.Text) + ""; ;
cmd.Connection = con;
da.SelectCommand = cmd;
DataSet ds = new DataSet();
ds.Clear();
con.Open();
da.Fill(ds, "y14n");

DataTable dt = new DataTable();
da.Fill(dt);
con.Close();
//------------------------Report
stiReport1.Load("Report.mrt");
stiReport1.RegData("dt14n", dt);
this.Hide();
stiReport1.Show();
}
catch { }

sadegi
یک شنبه 07 دی 1393, 23:51 عصر
?How Do I Change the Text of a Query When Rendering
You can use report parameters to achieve this. By default, the report engine does not support
parameters as standard view point. For example, consider this query
select * from customers where code = :code
In this case you cannot detect the value of :code. However, you can use an expression linked to report
variables to form any part of an SQL query. For example
{select * from customers where code = {myvariable
{select * from customers where {myvariable
{select * from customers {myvariable
select * from {myvariable} where code=1
{()select * from customers where code = {MyStaticClass.GetCondition
{select * from customers where {Datasource.Condition
select {myvar+myvar2} from customers

sadegi
یک شنبه 07 دی 1393, 23:53 عصر
How Do I Add a Parameter to an SQL query?
In the data source you should create a parameter. In the SQL query you write:
select * from customers where customerid=@customerid
Then you need to initialize this parameter. For example, to initialise it in code you do something like
this:
C#‎‎‎
StiReport report = new StiReport();
report.RegData(myDataset);
report.Compile();
report["@customerid"] = 1;