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 1024 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 weeks old. It deletes data from
33 tables and the number of rows in each table runs into few millions.
What I see in the script (not written by me :-) ) is that all data is
deleted within a single BEGIN TRANSACTION and COMMIT TRANSACTION. As
|
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 am using Transaction for each
insert statement. But when i try to insert it is
displaying "use of unassigned local
variable 'InsertTrans'. Can anybody help me.
My code is as follows.
|
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 continously giving me error on the
following line,
transaction = Connection.BeginTransaction();
System.Data.SqlClient.SqlException: New transaction is not allowed
because
|
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 dblink (into the
same database)?
Does the SQL statement executed within the dblink sit in its own isolated
transaction/session? And would an error thrown in the dblink statement
abort the enclosing session that initiated the call?
What is 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
http://groups.google.com/group/comp.databases.ms-sqlserver/browse_thread/thread/1063b65df1f97492/8649bee2002646a2
By using the new "Row versioning" functionality of SQL 2005, it
completely solved this problem. By reading the books online, it says
there is a performance impact,...
|
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 SP, I'm starting the transaction as well, with savepoint.
|
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 SOMETIMES one of tables naming 'AimD' has no record although table 'AimB' has a record.But according to transaction it must HAVE. A very important consideration is that the table 'AimD' is getting 1 million records everyday and approximately 1 to 7...
|
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 sheet is needed to print at the end of the day. It is the list of items, inventory cost, inventory units, and inventory amount
When items of the same type were purchased at different unit cost, it is the question as to how to calculate the unit...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |