TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
GR M
NA
5
19.9k
Null reference exception in Transaction
Dec 31 2010 2:09 AM
Im having problem with a null reference exception while executing the code
trans.Rollback() . Kindly help ASAP.
Thanx in Advance.
FYI:
Dim trans As OleDbTransaction
Try
trans = con.BeginTransaction
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim cmd_inward As OleDbCommand = New OleDbCommand("Insert into inward_entry(in_date,product_name,batch_no,Pack,type, qty,Description,Mfd_Company,Exp_Date,Purchased_price,MRP) values (#" & Todate & "#,'" & Prd_nm & "', '" & Prd_batch & "','" & Prd_pack & "', '" & prd_type & "','" & item_Qty & "', '" & prd_description & "','" & Mfd_By & "','" & exp_dt & "', '" & Pur_prc & "','" & Prd_MRP & "')", con)
cmd_inward.Transaction = trans
cmd_inward.ExecuteNonQuery()
Dim cmd_pur_mast As OleDbCommand = New OleDbCommand("insert into purchase_master (purchase_date,product_name,item_pack,Batch_no,product_purchase_price,item_qty) values (#" & Todate & "#, '" & Prd_nm & "','" & Prd_pack & "','" & Prd_batch & "', '" & Pur_prc & "','" & item_Qty & "')", con)
cmd_pur_mast.Transaction = trans
cmd_pur_mast.ExecuteNonQuery()
Dim cmd_prd_mast As OleDbCommand = New OleDbCommand("insert into product_master(product_name, item_pack,product_manufacturer,product_description) values ('" & Prd_nm & "','" & Prd_pack & "','" & Mfd_By & "','" & prd_description & "')", con)
cmd_prd_mast.Transaction = trans
cmd_prd_mast.ExecuteNonQuery()
Dim cmd_select_warehouse As OleDbCommand = New OleDbCommand("Select * from warehouse_master where product_batch_no='" & Prd_batch & "' and product_name='" & Prd_nm & "' and item_pack='" & Prd_pack & "' ", con)
Dim rdr As OleDbDataReader
rdr = cmd_select_warehouse.ExecuteReader()
If rdr.Read() = False Then
Dim cmd_insert As OleDbCommand = New OleDbCommand("Insert into warehouse_master(product_batch_no, product_manufacturer, product_name,item_pack, available_qty,product_exp_date,product_MRP) values('" & Prd_batch & "','" & Mfd_By & "','" & Prd_nm & "', '" & Prd_pack & "','" & item_Qty & "', '" & exp_dt & "', '" & Prd_MRP & "')", con)
cmd_insert.Transaction = trans
cmd_insert.ExecuteNonQuery()
Else
MessageBox.Show("data")
Dim cmd_update As OleDbCommand = New OleDbCommand("Update warehouse_master set available_qty= available_qty + '" & item_Qty & "' where product_batch_no = '" & Prd_batch & "' and product_Name = '" & Prd_nm & "' and Item_pack= '" & Prd_pack & "'", con)
cmd_update.Transaction = trans
cmd_update.ExecuteNonQuery()
End If
trans.Commit()
Catch ex As Exception
trans.Rollback()
MessageBox.Show("Transaction Rolled Back")
Finally
con.Close()
End Try
Reply
Answers (
7
)
How to get Div tag contents only Using c#
Stylesheet manager control