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

Transaction Problem

19
I'm having problem With a Null reference exception Error message when running the later part of the code. i.e
Expand|Select|Wrap|Line Numbers
  1. trans.Rollback()
  2.  
FYI:
Expand|Select|Wrap|Line Numbers
  1. Dim trans As OleDbTransaction
  2.  
  3.         Try
  4.             trans = con.BeginTransaction
  5.             If con.State = ConnectionState.Closed Then
  6.                 con.Open()
  7.             End If
  8. 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)
  9.             cmd_inward.Transaction = trans
  10.             cmd_inward.ExecuteNonQuery()
  11.             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)
  12.             cmd_pur_mast.Transaction = trans
  13.             cmd_pur_mast.ExecuteNonQuery()
  14.             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)
  15.             cmd_prd_mast.Transaction = trans
  16.             cmd_prd_mast.ExecuteNonQuery()
  17. 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)
  18.             Dim rdr As OleDbDataReader
  19.             rdr = cmd_select_warehouse.ExecuteReader()
  20. If rdr.Read() = False Then
  21. 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)
  22.                 cmd_insert.Transaction = trans
  23.                 cmd_insert.ExecuteNonQuery()
  24.  
  25.             Else
  26.                 MessageBox.Show("data")
  27.                 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)
  28.                 cmd_update.Transaction = trans
  29.                 cmd_update.ExecuteNonQuery()
  30.  End If
  31.  
  32.             trans.Commit()
  33.         Catch ex As Exception
  34.  trans.Rollback()
  35.  
  36.             MessageBox.Show("Transaction Rolled Back")
  37.         Finally
  38.             con.Close()
  39.         End Try
  40.  
  41.  
Sort Out The problem and give the exact cause. Thanks In advance.
Dec 31 '10 #1
0 1008

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: rkusenet | last post by:
Hi, I am still not very proficient in SQLServer. So apology if the question sounds basic. We have a script to clean old unwanted data. It basically deletes all rows which are more than 2...
7
by: denis | last post by:
Hello I'm trying to run this code but i get an error: "Object reference not set to an instance of an object. " Can somebody help me? Thanks Try ...
4
by: Ramesh | last post by:
hi I am trying to insert random values to the tables. I will get no.of records value from user, based on that loop will start to insert records. For this insertion i am using stored procedure. I...
2
by: Beenz | last post by:
Hello, I am developing an application in C#, which was previously in .Net 2005 Beta, then it was working perfectly fine, but from the time I have upgraded it to .Net 2.0 Professional, its...
9
by: John Sidney-Woollett | last post by:
Is it possible to use the dblink and dblink_exec features from inside pl/pgsql functions to mimic the behaviour of nested transactions by calling another function or executing some SQL via the...
1
by: pb648174 | last post by:
I just wanted to post a follow up to a message I posted some months ago about a long running transaction that was blocking all other users... The link is below ...
2
by: Habib | last post by:
CREATE PROCEDURE SimpleInsert ( @custname custname_type, @carname carname_type) AS BEGIN TRANSACTION INSERT Customers (CustName) VALUES (@custname)
0
by: Matik | last post by:
Hi, MSSQL 2000 booth servers. Booth running DTC. Now, the client application, is starting in DB1 a procedure. The connection open to db, is within the transation opened from client. In the...
1
by: alenak | last post by:
Hi Everybody, I have a web application that makes large number of insertions and updates in DB. In this application I send a sql query which is sql transaction shown below. The problem is that...
1
kiemxai
by: kiemxai | last post by:
you see that,i did correct or not? PROBLEM ANALYSIS For an introduction to program transaction journal, see the background section of assignment . Not only transaction journal, but also inventory...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.