How can I solve this problem? Is there a possibility?
Hello, I downloaded the demo .net version from your site. to experiment. I installed the program on the computer. trial version. I make a SQL connection and design the report in the design program within the package. But I want to introduce you to the problem I constantly experience. I am providing a dataset with the same content from NET 6 webapi. While calling the design in the report.load section, it searches for connection information. But there is no connection information in the project. How to give direct data and display the report? I do not want to use the connection information used in the design. How can I solve this problem? Is there a possibility?
Comments
Try open [YourReport].frx with TextEditor and compare example report "Simple List.frx" then remove the <MsSqlDataConnection> tag and change the <TableDataSource> tag to the same as in the example.
Is there a way to do it with this code?
======================================================================================================
<?xml version="1.0" encoding="utf-8"?>
<Report ScriptLanguage="CSharp" ReportInfo.Created="12/26/2024 11:31:32" ReportInfo.Modified="12/26/2024 11:37:54" ReportInfo.CreatorVersion="2025.1.0.0">
<Dictionary>
<MsSqlDataConnection Name="_conn" ConnectionString="rijcmlq8Yfcg/vHPFtvc+PG76BuCV5McE51k44VNv6m+/0kIooIbYW5ZSrX3JxxJysRknwE2FuhWkvjt0L/GUYo0A1nwi+HZnO7vvWPRlt5EY32MufWWeqiN12JMJn//kqGYgIMfjhadc+jBIk35QiOdGQH70n2ILUHYj8E6+FzVdZ+FV1trdJcp480GNL1o+19ovUXF+nrCB9vq/6OE3NYUZjAQg==">
<TableDataSource Name="cari" DataType="System.Int32" PropName="tbl_cari_hesap" Enabled="true" TableName="tbl_cari_hesap">
<Column Name="ref_no" DataType="System.Int64"/>
<Column Name="cari_kodu" DataType="System.String"/>
<Column Name="cari_ad_unvan" DataType="System.String"/>
<Column Name="yetkili_kisi" DataType="System.String"/>
<Column Name="fatura_adresi1" DataType="System.String"/>
<Column Name="fatura_adresi2" DataType="System.String"/>
<Column Name="fatura_adresi3" DataType="System.String"/>
<Column Name="vergi_numarasi" DataType="System.String"/>
<Column Name="vergi_dairesi" DataType="System.String"/>
</TableDataSource>
</MsSqlDataConnection>
</Dictionary>
<ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
<ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/>
<PageHeaderBand Name="PageHeader1" Top="41.8" Width="718.2" Height="28.35">
<TextObject Name="Text2" Left="9.45" Width="94.5" Height="18.9" Text="ref_no" Font="Arial, 10pt"/>
<TextObject Name="Text4" Left="113.4" Width="94.5" Height="18.9" Text="cari_kodu" Font="Arial, 10pt"/>
<TextObject Name="Text6" Left="217.35" Width="94.5" Height="18.9" Text="cari_ad_unvan" Font="Arial, 10pt"/>
</PageHeaderBand>
<DataBand Name="Data1" Top="74.15" Width="718.2" Height="28.35" DataSource="cari">
<TextObject Name="Text1" Left="9.45" Top="9.45" Width="94.5" Height="18.9" Text="[cari.ref_no]" Font="Arial, 10pt"/>
<TextObject Name="Text3" Left="113.4" Top="9.45" Width="94.5" Height="18.9" Text="[cari.cari_kodu]" Font="Arial, 10pt"/>
<TextObject Name="Text5" Left="217.35" Top="9.45" Width="94.5" Height="18.9" Text="[cari.cari_ad_unvan]" Font="Arial, 10pt"/>
</DataBand>
<PageFooterBand Name="PageFooter1" Top="106.5" Width="718.2" Height="18.9"/>
</ReportPage>
</Report>
Hi,
I made a simple coding in C# and it works now. but it may be useful to other people as well. I wanted to share it with you in case I made a mistake. This is how I fix it and it works. Thank you very much everyone.
Sample Code :
==============================================
public Stream ConvertFrxtoStream(string frxfile, string tagname)
{
var stream = new MemoryStream();
try
{
string xmlstring = File.ReadAllText(frxfile);
int index = xmlstring.IndexOf(@"<"+ tagname);
int len = (@"<"+tagname).Length;
string strreplace="";
if (index > 0)
{
for (int i = index; i < xmlstring.Length; i++)
{
string chx = xmlstring[i].ToString();
strreplace += chx;
if (chx == @">")
{
break;
}
}
if (strreplace.Length > 0)
{
xmlstring = xmlstring.Replace(@"</"+tagname+">", "");
xmlstring = xmlstring.Replace(strreplace, "");
}
}
int startindex = 0;
int endindex = 0;
while (startindex != -1)
{
strreplace = "";
tagname = "TableDataSource";
startindex = xmlstring.IndexOf(@"<" + tagname, startindex+5);
if (startindex == endindex) startindex = -1;
if (startindex > 0)
{
endindex = startindex;
for (int i = startindex; i < xmlstring.Length; i++)
{
string chx = xmlstring[i].ToString();
strreplace += chx;
if (chx == @">")
{
break;
}
}
int pos = strreplace.IndexOf("Name");
int indexof = strreplace.IndexOf(@"=", pos+1);
int adet = 0;
string namevalue = "";
for (int i = indexof; i < strreplace.Length; i++)
{
string chx = strreplace[i].ToString();
if (chx == @"""")
{
adet++;
if (adet>1) break;
}
else
{
if (adet > 0) namevalue += chx;
}
}
xmlstring = xmlstring.Replace(strreplace, @"<TableDataSource Name='"+ namevalue + "' ReferenceName='Data." + namevalue + "' DataType='System.Int32' Enabled='true'>");
}
}
xmlstring = xmlstring.Replace("'", "\"");
// PropName = "tbl_cari_hesap" TableName = "tbl_cari_hesap"
var writer = new StreamWriter(stream);
writer.Write(xmlstring);
writer.Flush();
stream.Position = 0;
}
catch {
}
return stream;
}
var cari = ConvertToDataTableList(data.Data.Items.ToList());
cari.TableName = "cari";
var reportStream = ConvertFrxtoStream(frxfile, "MsSqlDataConnection");
var fs = FastReport.Report.FromStream(reportStream);
DataSet ds = new DataSet();
ds.Tables.Add(cari);
fs.RegisterData(ds);
fs.Prepare();
using (MemoryStream ms = new MemoryStream())
{
PDFSimpleExport export = new PDFSimpleExport();
export.Export(fs, ms);
// export.Export(fs, frxfile+".pdf");
// base64Pdf = Convert.ToBase64String(ms.ToArray());
}