Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

SQL
<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
Posted
Updated 9-Apr-14 10:50am
v4

1 solution

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
 
Share this answer
 
Comments
Subha2531 9-Apr-14 16:22pm    
Actually I am calling a webmethod in web service (asmx) from the application. So I tried proxyObj.TimeOut=999999... //proxyObj is the instance for the web service proxy
I have few other similar web methods with da.update(ds,"tblname") which works fine. Only one webmethod is throwing exception... It has like 14000 rows which in not that big???!!!
Subha2531 9-Apr-14 16:24pm    
I also found that after getting the webexception, the dataset keeps inserting the records to the db till end. I dunno whether that is possible!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900