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 Databases Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
Old April 28th, 2005, 04:15 AM
Friend of Wrox
 
Join Date: Apr 2005
Location: Cochin, , India.
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.


Reply With Quote
  #3 (permalink)  
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
Reply With Quote
Reply


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
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



All times are GMT -4. The time now is 02:35 PM.


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