直接流传输到数据库 [英] Streaming directly to a database

查看:218
本文介绍了直接流传输到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#,并有一个开放的TCPIP连接接收数据。是否有可能保存流到MS SQL Server数据库因为我接受它,而不是接收的所有数据,然后保存它呢?如果该流可以被发送到数据库,因为它是被接收,则就不必保留的数据的全部块中的存储器。这是在所有可能的?

I'm using c#, and have an open tcpip connection receiving data. Is it possible to save the stream to an ms sql server database as I'm receiving it, instead of receiving all the data then saving it all? If the stream could be sent to the database as it's being received, you wouldn't have to keep the entire chunk of data in memory. Is this at all possible?

推荐答案

您写入数据库为BLOB或转换数据以某种形式,然后执行插入的每一行?

Are you writing to the DB as a BLOB, or translating the data in some form, then executing inserts for each row?

您在评论中回答了我的困惑。写一个流BLOB列是千差万别的,然后获取数据,然后将其转化为插入不同的行。

Your answer in the comments has me confused. Writing a stream to a BLOB column is vastly different then getting the data then translating it into inserts for separate rows.

无论如何,洒进BLOB列可以通过首先创建与你需要插入,反复调用一个UPDATE语句中BLOB列的行:

Regardless, streaming into a BLOB column is possible by first creating the row with the blob column that you need to insert into, the repeatedly calling an update statement:

update myTable set myColumn.Write(@data, @offset, @length) where someid = @someId

有关字节块从流中。

<一个href="http://weblogs.asp.net/alessandro/archive/2008/09/22/conserving-resources-when-writing-blob-values-to-sql-server-and-streaming-blob-values-back-to-the-client.aspx"相对=nofollow>完美的例子,设在这里。

这篇关于直接流传输到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆