I'm having problem With a Null reference exception Error message when running the later part of the code. i.e
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
-
-
Sort Out The problem and give the exact cause. Thanks In advance.
0 1008 Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
...
|
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...
|
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...
|
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...
|
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
...
|
by: Habib |
last post by:
CREATE PROCEDURE SimpleInsert (
@custname custname_type,
@carname carname_type)
AS
BEGIN TRANSACTION
INSERT Customers (CustName) VALUES (@custname)
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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,...
|
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...
|
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...
|
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...
| |