Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 November 18th, 2007, 02:56 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking for duplicate entry in Database

Hi,

I am trying to stop a duplication of a order being processed by querying the database to see if the duplicate order number exists and then use an IF statement to provide a message to stop it being duplicated.

I am able to open the connection to the database as follows but not sure on how to query it to find out if this particular order number exists to be able to then include the IF statement: -

DBConnection = New OleDbConnection ( _
  ConfigurationSettings.AppSettings("ConnectionStrin g"))
DBConnection.Open()
SQLString = "SELECT * FROM ShopBasket INNER JOIN Products " & _
 "ON ShopBasket.ItemNumber = Products.ItemNumber " & _
 "WHERE OrderNumber = '" & Session("OrderNumber") & "' " & _
 "ORDER BY ShopBasket.ItemNumber"
DBCommand = New OleDbCommand(SQLString, DBConnection)
DBConnection.Close()

Please can anyone assist me with this problem.

Many Thanks
Sharon

 
Old November 18th, 2007, 06:08 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can use the SQL syntax

if exists
(
  <sql query>
)
<do something>
else
<do something else>

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate database entry redirection error page EmWebs Dreamweaver (all versions) 3 December 29th, 2006 10:17 AM
Duplicate database entry redirection error page EmWebs Access ASP 0 December 27th, 2006 12:54 PM
avoid duplicate entry of records mikersantiago Classic ASP Basics 4 February 10th, 2005 09:14 PM
deleting only 1 duplicate entry qwjunk Classic ASP Databases 3 February 2nd, 2004 11:45 AM
Checking for a entry in access aadz5 ASP.NET 1.0 and 1.1 Basics 4 November 17th, 2003 10:49 PM





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