Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 Databases by Thearon Willis; ISBN: 9780764588945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 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
 
Old July 18th, 2006, 02:48 PM
Authorized User
 
Join Date: Jul 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert

When inserting records using stored procedures why are the methods in the classes always defined as functions that return a boolean?
Is this because SQL will pass back a true or false depending on whether the stored procedure executed?


 
Old July 21st, 2006, 01:13 AM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. Since the Application is distributed across several layers, you have to have some way for a call from one layer to a lower layer, to know whether the call succeeded/failed. Hence the functions are coded to return Booleans. hth.

 
Old July 24th, 2006, 05:03 PM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

The design was to keep the logic simple. When you execute a function to insert a record from your Windows form, you can use the execute statement in an If...Then block. Actually, the ExecuteNonQuery method will return the number of rows affected by the insert statement thus inserting a single record will return a 1 and not inserting a record will return a 0. Remember that a Boolean value contains a value of 0 for False and any other number other than 0 for True, which is usually 1. This makes the function return a 0 when False and any number other than 0 will correlate to a value of True.

Thearon





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert " ". Somesh C# 1 March 6th, 2007 08:45 AM
insert into U.N.C.L.E. SQL Language 3 June 6th, 2006 06:35 PM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM
Insert into jemacc SQL Server 2000 2 March 31st, 2004 08:31 AM
"INSERT INTO" kaz SQL Language 7 December 15th, 2003 07:40 PM





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