Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 April 28th, 2005, 03:53 AM
vbmazza
Guest
 
Posts: n/a
Default Checking a Database before Inserting a Record

Hi,

I need to check two fields/columns within my SQL database before inserting a new record.

Basically I have a Name field and a Date field, I want to check if a name exists with a specific date before I insert what would be a duplicate record. I can have multiple instances of name or date but not both together.

I am using Visual Basic .Net within Visual Studio, can anyone help?

Thanks

VBMazza
 
Old April 28th, 2005, 04:15 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Compare them in the WHERE clause of the INSERT Query.
Now To confirm the Insertion check the RecordsAffected returned by the ExecuteNonQuery.

Regards,
Prashant.


 
Old April 28th, 2005, 07:23 AM
vbmazza
Guest
 
Posts: n/a
Default

Thanks,

I used the WHERE statement in a SELECT command, then used a Data Reader to give a
BOOLEAN response, so I can give the user an option to edit a record.

VBMazza





Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking to see if record exists EmmaGale Classic ASP Basics 6 March 14th, 2006 02:39 AM
Checking Data Before Inserting rit01 ASP.NET 2.0 Professional 17 February 28th, 2006 09:17 AM
Inserting A Record Set nikotromus Access VBA 3 September 14th, 2004 01:23 PM
Checking for duplicate record in jsp Regornil JSP Basics 0 July 30th, 2004 01:55 AM
Select record after inserting it whyulil Classic ASP Databases 13 April 26th, 2004 06:05 AM





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