Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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
Reply With Quote
  #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


Reply With Quote
  #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:
================================================== =========
Reply With Quote
  #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.


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:20 PM.

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