I have a product table id int and name varchar 50 I also have an image table id int productid int imageurl varchar 50
product id -------------- the picture is very related to the product id 1 to 1
product id=1 image productid=1 imageurl=/images/1.jpg
product id=1 image productid=1 imageurl=/images/2.jpg
product id=1 image productid=1 imageurl=/images/3.jpg
Now I created a mydataset.xsd file and created two tables with datatable add.
One of them has id and name in datatable1, the other table datatable2 has id, productid and imageurl.
I definitely did not use dataadaptor here
I did not use dataadaptor here. I will do everything in action
Now I created a report with add, I called its datasource mydataset,
I added id and name under Onururun name id and name in the dataset,
again I created id, urunid, pictureurl under the image name with add,
then I placed 2 table elements in the report, I called id in the first column and name in the second column,
I added the 2nd table in the first column, id in the second.
productid I added an image element to the third one. My aim is to get the path information in the imageurl variable from the physical images folder and display it with microsoft.reportviewer.
In the parameters section of the report, I named a variable with add, its name is resimyoluprmt.
I said "~/resimler/" and then I said embeeded to the report un select image source and added =Parameters!resimyoluprmt.Value to the use this image section.
I said this, then it was time to write the action.
protected void Page_Load(object sender, EventArgs e)
{
deger = Request.QueryString["bulid"];
if (!Page.IsPostBack)
{
string resimKlasorYolu = "~/resimler/"; // Parametre olarak alınacak resim klasörünün yolu
string connectionString = @"Data Source=DESKTOP-1B3OQRL;Initial Catalog=ibroz;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter da = new SqlDataAdapter("SELECT product.*, picture.* FROM urun INNER JOIN picture ON product.id = pictute.urunid WHERE picture.id='" + deger + "'", connection);
DataTable dtUrun = new DataTable();
DataTable dtResim = new DataTable();
da.Fill(dtUrun);
da.Fill(dtResim);
// Parametreye resim klasör yolunu ekleyerek resim yollarını güncelle
foreach (DataRow row in dtResim.Rows)
{
row["pictureurl"] = resimKlasorYolu + row["pictureurl"];
}
// Rapor dosyasına parametreyi ekle
ReportParameter[] parameters = new ReportParameter[1];
parameters[0] = new ReportParameter("resimyoluprmt", resimKlasorYolu);
ReportViewer1.LocalReport.SetParameters(parameters);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
//ReportViewer1.LocalReport.ReportPath = Server.MapPath("report1.rdlc");
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/report1.rdlc");
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("onururun", dtUrun));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("resimm", dtResim));
ReportViewer1.LocalReport.Refresh();
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="baski.aspx.cs" Inherits="onibrticari.WebForm1" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
</div>
</form>
</body>
</html>
but the code gives this error "The source of the report definition has not been specified"}, whereas report1.rdlc exists under no folder in my asp net project.