如何在托管 SQL Server/IIS 环境中使用 BCP? BCP 的替代方案是什么
我有一个用 ASP 构建的 Web 应用程序,最初托管在我自己的本地服务器上 - Win 2008、IIS 7.0、SQL Server 2008。
然后我购买了一个折扣 ASP.Net 网站 + 数据库托管帐户。
Web 应用程序从网站根目录下的文件夹中获取文件,并将其批量插入到数据库中的记录中。在本地开发盒上一切正常。
当数据库+网站移动到DiscountASP.Net托管帐户时,BULK INSERT将不起作用,DiscountASP.Net告诉我们不允许BULK INSERT,因为托管数据库服务器是共享服务器。
这种情况的解决方法是什么?他们表明我们可以使用单独的 INSERT。
有更好的解决方案吗?有人遇到过类似的问题并有一些我们可以重复使用的解决方案吗? (而不是重新发明轮子)。
感谢您查找我的问题。
I have a web application built in ASP and initially hosted on my own local server - Win 2008, IIS 7.0, SQL Server 2008.
I then bought a discountASP.Net hosting account for website + database.
The web application takes a file from a folder under the website root and bulk inserts into records in the database. Everything worked fine on the local development box.
When the database + website was moved to the DiscountASP.Net hosted account, the BULK INSERT would not worked and DiscountASP.Net told us that BULK INSERT is not allowed since the hosted database server is a shared server.
What is the work around for this scenario? They have indicated that we could use individual INSERTs.
Is there are better solutions out there? Has someone faced a similar problem and have some solution in place that we can re-use? (rather than reinventing the wheel).
Thanks for looking up my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
经过一番尝试,我自己找到了解决方案。以下是解决方案步骤(由于客户端机密性,我无法共享代码):
我使用 Scripting.FileSystemObject 服务器对象从 ASP 代码读取 Web 服务器上文件中的所有文本。
我将文件的整个文本作为变量传递给存储过程 (SQL Server 2008)。参数的数据类型必须为“adLongVarChar”请参阅此处的数据类型表(如果枚举无法识别,就像我的情况一样,我使用值 201 而不是枚举)。
在存储过程中编写 SQL 代码,将字符串解析为行,然后进一步将每一行解析为列值。
希望我的解决方案的伪代码对某人有所帮助。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您必须使用 .net 中的 SQLBulkCopy 或发送 XML 以便在 SQL 代码中进行解析
You'd have to use SQLBulkCopy from .net or send in XML to be parsed in SQL code