<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
'declare connection
dim Conn as new OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;"))
sub Page_Load(Sender as Object, e as EventArgs)
dim objTrans as OleDbTransaction
dim objCmd as OleDbCommand = new OleDbCommand _
("DELETE from employee where UserID = 32", Conn)
Conn.Open()
objTrans = Conn.BeginTransaction()
objCmd.Transaction = objTrans
try
objCmd.CommandText = "INSERT INTO employee " & _
"(ID, FirstName, LastName) VALUES " & _
"(109, 'J', 'S')"
objCmd.ExecuteNonQuery()
objCmd.CommandText = "INSERT INTO employee " & _
"(ID, FirstName, LastName) VALUES " & _
"(119, 'J', 'S')"
objCmd.ExecuteNonQuery()
objTrans.Commit()
Label1.Text = "Both operations performed successfully"
catch ex as OleDbException
objTrans.RollBack()
Label1.Text = ex.Message & ""
Label1.Text = "Both operations failed"
finally
objCmd.Connection.Close()
end try
end sub
</script>
<html><body>
<form runat="server">
<asp:Label id="Label1" runat="server"
maintainstate=false /><br>
</form>
</body></html>
|