Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 9th, 2008, 12:52 AM
Registered User
Join Date: May 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database not getting updated

Hello everybody in the problem solving world !!!!.........

Well I have come across a unique problem and am not able to find any logic behind that.

My vb.net application runs on a sql server 2000 and it is about making bills in a fast running gift counter with 5 to 6 client and server is placed at a distance of 200 meters. The store sells maximum of 50-60 gifts. The user does all the transaction through clicks.

Two tables are involved for making a transaction. One is mastertable and detailtable.

In the mastertable my application is inserting the total of the bill, date, amount and the counter person’s code. It then generates an auto number which I picks up after the data is inserted in the mastertable and then uses the same in the detailtable.

The detailtable holds fields like item, qty, rate,id of mastertable etc.

My application is running smooth, but recently I noticed that say one in 500th time, row is not added to mastertable while it is present in detailtable with the id of mastertable. I have binded the sql with commit. I have digged my code but am not finding any logic behind this error.

Please help. Thanks in advance.
  #2 (permalink)  
Old May 13th, 2008, 11:33 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts


that is weird...

even still using commit... u have this problem... then it's unbelievable. can you post a sample script of your stored procedure on how you have approaching this..?

in general using commmit wont do a trick, it also depends on how the statement is stated.

look out points:
- how the transaction is began?
> are you inserting the data to tran table only after inserted in the master table?
- if anything goes wrong/internal script warning in inserting into tran table then are you rolling back the master data inserting statement?
- are you using error trapping system variable to see the statement execution result?
- any PK-FK warning?

I have so many such application where the concept of master-tran is used and i never faced such problems in real time.

So post some of the sample of your code here.. so it will help to see and understand your current process.

Hope this helps.

With Regards,
Raghavendra Mudugal
  #3 (permalink)  
Old May 15th, 2008, 07:11 AM
Registered User
Join Date: May 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the reply. Here is the code. Waiting for your suggestion.

con = connect()

'transaction begins here-------
trans = con.BeginTransaction()


'Data is inserted into mastertable---------

cmd = New SqlClient.SqlCommand("INSERT INTO mastertable(mbno,mbdate,mbamount,mbcperson) VALUES(" & counter_bill_no & ",'" & server_date & "'," & billvalue & "," & countercode & ")", con, trans)

cmd = New SqlClient.SqlCommand("select mbid from mastertable WHERE mbno=" & counter_bill_no & " and mbcperson=" & countercode & " ", con, trans)
mb_id = cmd.ExecuteScalar

'Data inserted into detailtable-----------

i = 0
For i = 0 To row_no - 1
selling_rate = DataGridView1.Item(2, i).Value
If selling_rate <> 0 Then
cmd = New SqlClient.SqlCommand("INSERT INTO detailtable(dbno,dbdate,dbicode,biquantity,dbamoun t) VALUES(" & mb_id & ",'" & server_date & "'," & DataGridView1.Item(4, i).Value & "," & DataGridView1.Item(1, i).Value & "," & DataGridView1.Item(3, i).Value & ")", con, trans)
End If
Next i

'Data commited--------


Catch ex As Exception

MsgBox("Bill could not be generated, Please try again.")

End Try


  #4 (permalink)  
Old May 15th, 2008, 07:39 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

Hi there.. how do you make the counter_bill_no?? maybe you a concurrency problem??



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========
  #5 (permalink)  
Old May 15th, 2008, 10:30 AM
Registered User
Join Date: May 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Say if we have 5 counters, counter_bill_no is seperate for each counters.

So we retrieve the maximum counter_bill_no for that particular counter through a query and than add it with 1.

Hope i am clear.


Similar Threads
Thread Thread Starter Forum Replies Last Post
updated report dominikm86 Crystal Reports 0 May 28th, 2007 01:03 PM
Database not updated tiredcat Visual Basic 2005 Basics 0 April 24th, 2007 08:49 PM
OPeration must be updated khzahid Classic ASP Basics 1 April 27th, 2005 06:01 PM
Last Updated Record mrideout BOOK: Beginning ASP.NET 1.0 1 September 20th, 2004 09:50 AM
Data not getting updated Renu ASP.NET 1.0 and 1.1 Basics 10 August 21st, 2004 05:39 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.