在数据库中存储Crystal Reports文件?

时间:2022-10-17 23:35:46

I've got a UI front end which talks to and manipulates a SQL Server database, and one of the things it can do is run reports on the data in the database.

我有一个UI前端,可以与SQL Server数据库进行对话和操作,它可以做的一件事是运行数据库中数据的报告。

This UI can be installed on multiple computers, and so far I've just been keeping the reports in a folder with the install, but this means that any time a new report is added is has to manually be copied to every single UI install out there.

这个UI可以安装在多台计算机上,到目前为止我只是将报告保存在安装文件夹中,但这意味着每次添加新报告时都必须手动将其复制到每个安装的UI中。那里。

I was thinking of storing the .rpt files in the database itself (As Blobs) and having some mechanism for the UI to fetch them when needed as a way to centralize the reports and eliminate this issue.

我正在考虑将.rpt文件存储在数据库本身(As Blobs)中,并在需要时使用一些UI来获取它们,以此作为集中报告和消除此问题的方法。

Has anybody tried this, and did it work well? Or if you haven't, can you think of anything I should take into account before moving forward with this? Are the any tips, tricks, or caveats you can think of that might be helpful to me?

有没有人试过这个,并且做得好吗?或者,如果你还没有,你能想到在继续前进之前我应该​​考虑的任何事情吗?您能想到的任何提示,技巧或警告可能对我有帮助吗?

4 个解决方案

#1


3  

Great Question! It's kind of coincidental as we've actually just implemented this within the last six months.

好问题!这有点巧合,因为我们实际上是在过去六个月内实施了这一点。

As you've suggested, we store the rpt file within the database, but do this in Server 2005 as a Image type. It works just fine and as far as the database goes, there really is no caveats that come to mind.

正如您所建议的那样,我们将rpt文件存储在数据库中,但在Server 2005中将其作为Image类型执行。它工作正常,就数据库而言,确实没有任何警告可以想到。

Obviously, the way you access this information changes with the API. If you're using C#, this translates to using a BinaryReader to load in the rpt file, grabbing a byte array. This byte array can then be passed to the database, through a stored procedure, etc.

显然,您访问此信息的方式随API而变化。如果您正在使用C#,则转换为使用BinaryReader加载rpt文件,获取字节数组。然后可以通过存储过程等将此字节数组传递给数据库。

I realize that you're asking specifically about blobs and Server 2008, but this works in both Server 2005 and Server 2008. Hope this sheds a bit of light.

我意识到你是专门询问blob和Server 2008,但这在Server 2005和Server 2008中都有效。希望这有点轻松。

If you need more specific details I'd be glad to share!

如果您需要更具体的细节,我很乐意与您分享!

#2


1  

Here's great podcast with Paul Randal (he wrote parts of DBCC!) where they talk about the new filestream feature in sql server 2008 for handling blobs, but they also go into the sizes of files that do and don't work well as blobs as part of the talk. I think it would help you. http://www.runasradio.com/default.aspx?showNum=74

这是与Paul Randal(他编写了DBCC的部分内容)的精彩播客,他们在sql server 2008中讨论了用于处理blob的新文件流功能,但是它们也涉及到作为blob运行和运行不正常的文件的大小。谈话的一部分。我认为这会对你有所帮助。 http://www.runasradio.com/default.aspx?showNum=74

I just found out that the 25-page FILESTREAM whitepaper Paul wrote has has been published on MSDN. http://msdn.microsoft.com/en-us/library/cc949109.aspx.

我刚刚发现Paul写的25页FILESTREAM白皮书已在MSDN上发布。 http://msdn.microsoft.com/en-us/library/cc949109.aspx。

Based on the research cited later in this white paper, BLOBs smaller than 256 kilobytes (KB) (such as widget icons) are better stored inside a database, and BLOBs larger than 1 megabyte (MB) are best stored outside the database. For those sized between 256 KB and 1 MB, the more efficient storage solution depends on the read vs. write ratio of the data, and the rate of “overwrite”. Storing BLOB data solely within the database (e.g., using the varbinary(max) data type) is limited to 2 gigabytes (GB) per BLOB.

根据本白皮书后面引用的研究,小于256千字节(KB)的BLOB(如小部件图标)最好存储在数据库中,大于1兆字节(MB)的BLOB最好存储在数据库之外。对于大小在256 KB和1 MB之间的用户,更高效的存储解决方案取决于数据的读取与写入比率以及“覆盖”率。仅在数据库内存储BLOB数据(例如,使用varbinary(max)数据类型)限制为每个BLOB 2千兆字节(GB)。

#3


1  

Okay so we all now that we can easily store a BLOB in a SQL SERVER, ORACLE, SQLITE, MYSQL Server and any other Database thats worth anything. What I am wondering is after you got the byte array out of the DB how did you create the report?

好的,我们现在都可以轻松地将BLOB存储在SQL SERVER,ORACLE,SQLITE,MYSQL Server和任何其他有价值的数据库中。我想知道的是,你从数据库中获取字节数组后,你是如何创建报告的?

I am wanting to do the same thing but the only thing that I can think of is pulling the file from the DB, creating a physical file in a Temp folder and then using the physical address of the new file to create the crystal Report. Is there any way to create a Crystal Report from a Memory Stream or byte Array?

我想做同样的事情,但我能想到的唯一一件事就是从数据库中提取文件,在Temp文件夹中创建一个物理文件,然后使用新文件的物理地址来创建晶体报告。有没有办法从内存流或字节数组创建Crystal报表?

#4


-1  

.RPT file could be stored in database(sql) by having it type as image.Store byte array into database and then retrieve it as stream.(HINT:Treat it as image file.)

.RPT文件可以通过将其键入为image来存储在数据库(sql)中。将字节数组存储到数据库中,然后将其作为流检索。(提示:将其视为图像文件。)

#1


3  

Great Question! It's kind of coincidental as we've actually just implemented this within the last six months.

好问题!这有点巧合,因为我们实际上是在过去六个月内实施了这一点。

As you've suggested, we store the rpt file within the database, but do this in Server 2005 as a Image type. It works just fine and as far as the database goes, there really is no caveats that come to mind.

正如您所建议的那样,我们将rpt文件存储在数据库中,但在Server 2005中将其作为Image类型执行。它工作正常,就数据库而言,确实没有任何警告可以想到。

Obviously, the way you access this information changes with the API. If you're using C#, this translates to using a BinaryReader to load in the rpt file, grabbing a byte array. This byte array can then be passed to the database, through a stored procedure, etc.

显然,您访问此信息的方式随API而变化。如果您正在使用C#,则转换为使用BinaryReader加载rpt文件,获取字节数组。然后可以通过存储过程等将此字节数组传递给数据库。

I realize that you're asking specifically about blobs and Server 2008, but this works in both Server 2005 and Server 2008. Hope this sheds a bit of light.

我意识到你是专门询问blob和Server 2008,但这在Server 2005和Server 2008中都有效。希望这有点轻松。

If you need more specific details I'd be glad to share!

如果您需要更具体的细节,我很乐意与您分享!

#2


1  

Here's great podcast with Paul Randal (he wrote parts of DBCC!) where they talk about the new filestream feature in sql server 2008 for handling blobs, but they also go into the sizes of files that do and don't work well as blobs as part of the talk. I think it would help you. http://www.runasradio.com/default.aspx?showNum=74

这是与Paul Randal(他编写了DBCC的部分内容)的精彩播客,他们在sql server 2008中讨论了用于处理blob的新文件流功能,但是它们也涉及到作为blob运行和运行不正常的文件的大小。谈话的一部分。我认为这会对你有所帮助。 http://www.runasradio.com/default.aspx?showNum=74

I just found out that the 25-page FILESTREAM whitepaper Paul wrote has has been published on MSDN. http://msdn.microsoft.com/en-us/library/cc949109.aspx.

我刚刚发现Paul写的25页FILESTREAM白皮书已在MSDN上发布。 http://msdn.microsoft.com/en-us/library/cc949109.aspx。

Based on the research cited later in this white paper, BLOBs smaller than 256 kilobytes (KB) (such as widget icons) are better stored inside a database, and BLOBs larger than 1 megabyte (MB) are best stored outside the database. For those sized between 256 KB and 1 MB, the more efficient storage solution depends on the read vs. write ratio of the data, and the rate of “overwrite”. Storing BLOB data solely within the database (e.g., using the varbinary(max) data type) is limited to 2 gigabytes (GB) per BLOB.

根据本白皮书后面引用的研究,小于256千字节(KB)的BLOB(如小部件图标)最好存储在数据库中,大于1兆字节(MB)的BLOB最好存储在数据库之外。对于大小在256 KB和1 MB之间的用户,更高效的存储解决方案取决于数据的读取与写入比率以及“覆盖”率。仅在数据库内存储BLOB数据(例如,使用varbinary(max)数据类型)限制为每个BLOB 2千兆字节(GB)。

#3


1  

Okay so we all now that we can easily store a BLOB in a SQL SERVER, ORACLE, SQLITE, MYSQL Server and any other Database thats worth anything. What I am wondering is after you got the byte array out of the DB how did you create the report?

好的,我们现在都可以轻松地将BLOB存储在SQL SERVER,ORACLE,SQLITE,MYSQL Server和任何其他有价值的数据库中。我想知道的是,你从数据库中获取字节数组后,你是如何创建报告的?

I am wanting to do the same thing but the only thing that I can think of is pulling the file from the DB, creating a physical file in a Temp folder and then using the physical address of the new file to create the crystal Report. Is there any way to create a Crystal Report from a Memory Stream or byte Array?

我想做同样的事情,但我能想到的唯一一件事就是从数据库中提取文件,在Temp文件夹中创建一个物理文件,然后使用新文件的物理地址来创建晶体报告。有没有办法从内存流或字节数组创建Crystal报表?

#4


-1  

.RPT file could be stored in database(sql) by having it type as image.Store byte array into database and then retrieve it as stream.(HINT:Treat it as image file.)

.RPT文件可以通过将其键入为image来存储在数据库(sql)中。将字节数组存储到数据库中,然后将其作为流检索。(提示:将其视为图像文件。)