473,401 Members | 2,139 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,401 software developers and data experts.

Transaction in MS Access

I am using ADO .Net and Access in a VB .Net app. Does MS Access support
Transaction(BeginTransaction, Commit, Rollback)?

Thanks.
Nov 21 '05 #1
4 4007
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:76**********************************@microsof t.com...
I am using ADO .Net and Access in a VB .Net app. Does MS Access support
Transaction(BeginTransaction, Commit, Rollback)?

Thanks.
Nov 21 '05 #2
Hi Ken,

I had tried "dim as OleDbDataAdapter" and "dim as OleDbConnection", but for
some reason they are not recognized as valid. When I hover the mouse over
the statement, it shows for example "Type OleDbConnection is not defined".
Is there anything I need to do prior to this? What could I be missing? Thank
you very much for your help!
"Ken Tucker [MVP]" wrote:
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:76**********************************@microsof t.com...
I am using ADO .Net and Access in a VB .Net app. Does MS Access support
Transaction(BeginTransaction, Commit, Rollback)?

Thanks.

Nov 21 '05 #3
Be sure you have this statement above the beginning of your Class:

Imports System.Data.OleDb

Then your Dim statements should work..............

james

"Monthep" <Mo*****@discussions.microsoft.com> wrote in message news:82**********************************@microsof t.com...
Hi Ken,

I had tried "dim as OleDbDataAdapter" and "dim as OleDbConnection", but for
some reason they are not recognized as valid. When I hover the mouse over
the statement, it shows for example "Type OleDbConnection is not defined".
Is there anything I need to do prior to this? What could I be missing? Thank
you very much for your help!
"Ken Tucker [MVP]" wrote:
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:76**********************************@microsof t.com...
I am using ADO .Net and Access in a VB .Net app. Does MS Access support
Transaction(BeginTransaction, Commit, Rollback)?

Thanks.

Nov 21 '05 #4
Make sure that at the very top of your class you have the line

imports System.Data.OleDb

That will solve the problem.
--
Pete Wright
Author of ADO.NET Novice to Pro for Apress
www.petewright.org

"Monthep" <Mo*****@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Hi Ken,

I had tried "dim as OleDbDataAdapter" and "dim as OleDbConnection", but
for
some reason they are not recognized as valid. When I hover the mouse
over
the statement, it shows for example "Type OleDbConnection is not defined".
Is there anything I need to do prior to this? What could I be missing?
Thank
you very much for your help!
"Ken Tucker [MVP]" wrote:
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:76**********************************@microsof t.com...
I am using ADO .Net and Access in a VB .Net app. Does MS Access support
Transaction(BeginTransaction, Commit, Rollback)?

Thanks.

Nov 21 '05 #5

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

Similar topics

3
by: Alan | last post by:
Gidday people, I had a bit of a problem this morning. I think I've got it sorted now, but I wonder if anyone can shed some light. I have a plain VBS WHS file that instantiates a component that...
0
by: DotNetJunkies User | last post by:
I am writing a distributed transaction code. My current scenario include a client database(Suppose client- having 4 main database) which can be installed anywhere which would connect to a public...
1
by: Frank Natoli | last post by:
Does START TRANSACTION and COMMIT apply only to the Connection for which the START TRANSACTION statement was performed? So if a second Connection is created, and used to access different tables in...
3
by: Lada 'Ray' Lostak | last post by:
Hi ! We are moving to PgSql application, with 'typical' style of work. Thin client, huge database. From database is (also) generated whole website. I will use it for explain my current todo....
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
2
by: ruben20 | last post by:
Hi: I've migrated a couple of weeks ago from 7.4.2 to 7.4.5 and I am getting this error after executing a query: Warning: pg_exec() query failed: ERROR: could not access status of transaction...
14
by: Jim Michaels | last post by:
mysql_query("START TRANSACTION", $link2); $q2=mysql_query("SELECT pictures.pid AS pid FROM pictures,counter WHERE pictures.pid>counter.pid LIMIT 1", $link2); if ($row2=mysql_fetch_assoc($q2)) {...
1
by: JA | last post by:
Hi, I know just about nothing about SQL Server. I am getting this error: The log file for database 'my_database' is full. Back up the transaction log for the database to free up some log space. ...
3
by: GaryDean | last post by:
I'm using TransactionScope as follows... using TransactionScope myScope = new TransactionScope()) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString =...
0
ADezii
by: ADezii | last post by:
In the Tip of the Week #19, we demonstrated Transaction Processing, specifically as it applies to DAO (Data Access Objects). In this week's Tip, we'll illustrate how Transaction Processing can be...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.