如何使用adapter.update()插入大量行而不会出现超时Web异常? [英] How to insert large number of rows using adapter.update() without getting timeout web exception?

查看:76
本文介绍了如何使用adapter.update()插入大量行而不会出现超时Web异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有类似于使用OLEDB dataadpter Update方法进行插入的开始和提交事务。



据我所知,交易可以在command.executequery。此外,dataadpter.Update()会自动将数据提交到datatble。如果我错了,请核对我。

这是我的代码



Dim conn As New Data.OleDb.OleDbConnection(My.Settings。 sConnStringEDIWeb)

conn.Open()

Dim da As New Data.OleDb.OleDbDataAdapter(SELECT * FROM CAB_,conn)

Dim builder As New Data.OleDb.OleDbCommandBuilder(da)

Dim ds As New DataSet(CAB_)

da.Fill(ds,CAB _)

Dim dt As DataTable = ds.Tables(CAB_)

For each dr As DataRow in ds.Tables(fetchTbl)。行

'dt.ImportRow(dr)不工作

Dim nr As DataRow = dt.NewRow

nr = dt.NewRow

nr( _NUM)= dr(_ NUM)

nr(PARENT)= dr(PARENT)

dt.Rows.Add(nr)

下一页

Dim bool As Boolean = da.Update(ds,CAB_)

返回布尔

结束函数n



我还得到webexception - 如果数据很大则超时。我知道sqlbulk copy有帮助,但在OLEDB中没有这样的等价物。我该如何解决?



任何帮助或领导都将不胜感激。在此先感谢。



此行错误:

Dim results()As Object = Me.Invoke(InsertMicroDataToEDIWEB,New Object (){ds})



这是在reference.vb中,因为我使用asmx web服务来插入数据。



Hi, I wonder if there is anything like begin and commit transactions for insert using OLEDB dataadpter Update method.

As far as I know transactions can be done on command.executequery. Also, dataadpter.Update() commits automatically the data to the datatble. Please corect me if I am wrong.
This is my code

Dim conn As New Data.OleDb.OleDbConnection(My.Settings.sConnStringEDIWeb)
conn.Open()
Dim da As New Data.OleDb.OleDbDataAdapter("SELECT * FROM CAB_", conn)
Dim builder As New Data.OleDb.OleDbCommandBuilder(da)
Dim ds As New DataSet("CAB_")
da.Fill(ds, "CAB_")
Dim dt As DataTable = ds.Tables("CAB_")
For Each dr As DataRow In ds.Tables("fetchTbl").Rows
'dt.ImportRow(dr) not working
Dim nr As DataRow = dt.NewRow
nr = dt.NewRow
nr("_NUM") = dr("_NUM")
nr("PARENT") = dr("PARENT")
dt.Rows.Add(nr)
Next
Dim bool As Boolean = da.Update(ds, "CAB_")
Return bool
End Function

Also I get webexception - timeout if data is large. I know sqlbulk copy helps, but there is no such equivalent in OLEDB. How can i fix that?

Any help or lead would be appreciated. Thanks in advance.

Error at this line:
Dim results() As Object = Me.Invoke("InsertMicroDataToEDIWEB", New Object() {ds})

This is in reference.vb as I am using asmx web servies to insert data.

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/InsertDataToEDIWEB", RequestNamespace:="http://tempuri.org/", ResponseNamespace:="http://tempuri.org/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _
        Public Function InsertMicroDataToEDIWEB(ByVal ds As System.Data.DataSet) As Boolean
            Dim results() As Object = Me.Invoke("InsertMicroDataToEDIWEB", New Object() {ds})
            Return CType(results(0),Boolean)
        End Function

推荐答案

您可以使用服务器。 ScriptTimeout设置请求超时值(您可以在执行数据库操作之前设置它)并尝试解决您的问题。喜欢:



You can use Server.ScriptTimeout to set request timeout value (you may set it just before performing the DB operation) and try if it solves your issue. Like:

Server.ScriptTimeout = 3600; //set request timeout to 60 min


这篇关于如何使用adapter.update()插入大量行而不会出现超时Web异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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