473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

OleDbtransaction?

How can I include the following code in a transaction? How can I set the
Transaction propertity for the call to MyDataAdapter.Update()? Thanks.

' Dim tr as OleDbtransaction = cnn.BeginTransaction
Dim dr As DataRow = MyDataSet.Tables("Customer").NewRow
dr(0) = "Smith"
MyDataSet.Tables("Customer").Rows.Add(dr)
MyDataAdapter.Update(MyDataSet,"Customer")
'tr.Commit
Nov 21 '05 #1
1 5110
Hi,
Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim strConn As String

Dim strSQL As String

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

DataGrid1.DataSource = ds '.Tables("Categories")

DataGrid1.DataMember = "Categories"

Dim tr As OleDbTransaction

Dim cmdBuild As New OleDbCommandBuilder(da)

Dim cmd As OleDbCommand = cmdBuild.GetUpdateCommand

da.UpdateCommand = cmd

conn.Open()

tr = conn.BeginTransaction

cmd.Transaction = tr

Dim dr As DataRow = ds.Tables("Categories").Rows(0)

Debug.WriteLine(da.UpdateCommand.CommandText)

dr.BeginEdit()

dr.Item("CategoryName") = "Drinks"

dr.EndEdit()

da.Update(ds, "Categories")

tr.Commit()

conn.Close()


Ken
-------------------------
"John" <Jo**@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
How can I include the following code in a transaction? How can I set the
Transaction propertity for the call to MyDataAdapter.Update()? Thanks.

' Dim tr as OleDbtransaction = cnn.BeginTransaction
Dim dr As DataRow = MyDataSet.Tables("Customer").NewRow
dr(0) = "Smith"
MyDataSet.Tables("Customer").Rows.Add(dr)
MyDataAdapter.Update(MyDataSet,"Customer")
'tr.Commit
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Joao Santa Barbara | last post by:
hi all i need to work with the commandbuilder and with a transaction object how can i do this ???? thks JSB please donīt tell me that i have to do this ex:
0
by: Sara | last post by:
I am getting an error that states: DB_E_ERRORSINCOMMAND when I try to establish a transaction in an Oracle 7.2 database. The code is: Try If AuthHelper.App_conn.State = ConnectionState.Closed...
0
by: Eyal Cohen | last post by:
Hello, i have a windows form application and i want to use an insert command within a transaction so i satrt the transaction : ( Conn is my connection object ) System.Data.OleDb.OleDbTransaction...
1
by: Steven K | last post by:
OK, I'm stumped. I am getting the error: Exception Details: System.Data.OleDb.OleDbException: Syntax error or access violation on the last line (spBusinessUnit =...
1
by: Bijoy Naick | last post by:
I am having trouble implementing transactions.. Here's my code.. ----- Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim myReader As OleDbDataReader Dim transaction As...
3
by: JimG | last post by:
In Microsofts Application blocks they comment the code directly in front of the Sub or Function, (an example is below). These commented lines allow the programmer to see the comments and...
1
by: alan | last post by:
I've use VB.NET+Access to write build a simple POS application. For example i got two computer, comp A and comp B. Which comp A share a Access db file through the network. When open a new bill, the...
0
by: Evandro Klen S. Azeredo | last post by:
Hi, I'm with the folowing problem: I have two tables: header(id_header) and Itens(id_header, id_item). When I insert data in Itens table, this error is returned: "You cannot add or change a...
0
by: tony | last post by:
Hello! Below I have three methods it's SavePost, SavePostSetUpTableFlg and SavePostBlowStepFlg. I want to use transaction to keep the data synchronized. All or nothing must be executed. When...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.